• What Are You Working On? - December 2014
    1,204 replies, posted
I need WAYWO's advice on something. I'm still not entirely sure what the best practice is for simple properties, so what does all of WAYWO prefer? [IMG]http://www.facepunch.com/fp/ratings/tick.png[/IMG] [code] public string Property { get; set; } [/code] [IMG]http://www.facepunch.com/fp/ratings/cross.png[/IMG] [code] public string Property { get { return this.property; } set { this.property = value; } } private string property; [/code] I personally think that the former is better, because unless you need to do something advanced when changing the property, there's no real benefit to having a public property shadow a private field, right?
If it's only getting and setting with no additional functionality or checking. Just use { get; set; }.
You can also make the field public (but you didn't hear this from me) [editline]4th December 2014[/editline] [QUOTE=mastersrp;46635235]Seems pretty interresting, although I don't have the time to read it all at the moment. Anyway, a thing that might be useful is stating which language you're specifically writing about. While I realize that it can be deduced to Haskell (GHC), that isn't expressly stated in the introduction, which could be useful just to put yourself and the reader on the same page from the start.[/QUOTE] Thanks for the tip! So easy to forget other people don't live in my head. Or do they...
[QUOTE=Darwin226;46635526]You can also make the field public (but you didn't hear this from me) [editline]4th December 2014[/editline] Thanks for the tip! So easy to forget other people don't live in my head. Or do they..[/QUOTE] Well, in that case, make your head tell our teacher how to fix the firewall issues we're having in class. 3 people have been having issues with Smoothwall, all related to the web proxy. And the third one has a completely correct configuration according to all the documentation we could find (I even fixed some errors by hand in the configuration file for squid, which were written incorrectly), but no luck so far. This is why I write my tools in C so I know what happens. And if shit goes wrong, I'll just ask for some pointers anyway.
[QUOTE=Contron;46635369]I need WAYWO's advice on something. I'm still not entirely sure what the best practice is for simple properties, so what does all of WAYWO prefer? [IMG]http://www.facepunch.com/fp/ratings/tick.png[/IMG] [code] public string Property { get; set; } [/code] [IMG]http://www.facepunch.com/fp/ratings/cross.png[/IMG] [code] public string Property { get { return this.property; } set { this.property = value; } } private string property; [/code] I personally think that the former is better, because unless you need to do something advanced when changing the property, there's no real benefit to having a public property shadow a private field, right?[/QUOTE] The first but format it on one line. [code] public string Property { get; set; } [/code]
[QUOTE=Darwin226;46635526]You can also make the field public (but you didn't hear this from me)[/QUOTE] I do this when optimizing code to avoid method call overhead from the getter/setter. Though, I suspect the compiler may already optimize that out. Doesn't hurt, either way.
[QUOTE=reevezy67;46635790]The first but format it on one line. [code] public string Property { get; set; } [/code][/QUOTE] With C# 6 there's even less reason to use a separate field as you can give a property a default value easily [CODE]public string Property { get; } = "Hello World!";[/CODE]
Started working on a basic text editor, with inspiration from the IBM Source Entry Utility.. Looks like shit, code is a mess.. but here's a picture with the readme open. [IMG]http://i.imgur.com/NuLmkFT.png[/IMG]
Thank you for the input/ratings everyone! I asked because I've seen code which uses both styles, and wasn't entirely sure which style was regarded as the best practice. The entire thing on one line makes even more sense, too.
[QUOTE=reevezy67;46635790]The first but format it on one line. [code] public string Property { get; set; } [/code][/QUOTE] "Don't put multiple statements on a single line unless you have something to hide" -Linus Torvalds [sp]But Torvalds is kind of a cunt anyways[/sp]
[QUOTE=proboardslol;46637357]"Don't put multiple statements on a single line unless you have something to hide" -Linus Torvalds [sp]But Torvalds is kind of a cunt anyways[/sp][/QUOTE] Pretty sure this isn't one of those cases considering they're not exactly classic statements.
Colorful Sin Wave represented in ascii [img]http://i.imgur.com/msu74T0.png[/img] [editline]4th December 2014[/editline] [QUOTE=Skipcast;46637462]Pretty sure this isn't one of those cases considering they're not exactly classic statements.[/QUOTE] I agree, it just reminded me of something he said
[QUOTE=Berkin;46634938]I finally figured out how to add syntax highlighting to RantBox. [img]http://i.imgur.com/O1hN4uz.png[/img] It's amazing what such a small thing does for readability. I should really make a standalone Rant editor, though.[/QUOTE] Then make it run inside C#, I don't know how, but it would be cool if you could make "modules", like: [code] var rantModule = Rant.Make("Your rant script here"); //makes rantModule string text = rantModule["Some function"](parameters here); //calls funtion and returns text. [/code] Or is that too much to ask for?
[QUOTE=esalaka;46631462]I guess it's technically not programming, but I can't see any other suitable place to complain about TeX. It produces lovely output but goddamn is it awful to write. [editline]4th December 2014[/editline] I'm writing something for school and as it involves formulae and graphs and MikTeX is pretty much the only suitable software package I had installed, I'm using LaTeX.[/QUOTE] I freaking love Latex. I'm using it for most of my assignments. About equations, sometimes when I have to write long ones I just use this. It evaluates your Latex equation really fast. [URL]http://www.codecogs.com/latex/eqneditor.php[/URL]
[QUOTE=Fourier;46637650]Then make it run inside C#, I don't know how, but it would be cool if you could make "modules", like: [code] var rantModule = Rant.Make("Your rant script here"); //makes rantModule string text = rantModule["Some function"](parameters here); //calls funtion and returns text. [/code] Or is that too much to ask for?[/QUOTE] Rant is made in C#, it already works in C# :P
[QUOTE=Berkin;46634938]I finally figured out how to add syntax highlighting to RantBox. [img]http://i.imgur.com/O1hN4uz.png[/img] It's amazing what such a small thing does for readability. I should really make a standalone Rant editor, though.[/QUOTE] Notepad++ plugin when?
I tried that one line code thing, and got a cool pattern that corrupts more and more over time: [url]http://vocaroo.com/i/s0VJqaSdZbaI[/url] Also uncompressed if you really like it: [url]https://www.dropbox.com/s/sfrd4dbdjb0ar61/audio.wav[/url]
[QUOTE=Arxae;46638141]Rant is made in C#, it already works in C# :P[/QUOTE] I am stupid as fuck sometimes, sorry. But still, good new :D [editline]4th December 2014[/editline] [QUOTE=DrDevil;46638430]I tried that one line code thing, and got a cool pattern that corrupts more and more over time: [url]http://vocaroo.com/i/s0VJqaSdZbaI[/url] Also uncompressed if you really like it: [url]https://www.dropbox.com/s/sfrd4dbdjb0ar61/audio.wav[/url][/QUOTE] It sounds really cool. Sell it to holywood for hacking sounds.
I tried to compose a little piece, I hope you guys like it: [url]http://vocaroo.com/i/s0KEFKK3WF5o[/url] Code: [url]http://pastebin.com/2AJntF2B[/url]
[QUOTE=MattJeanes;46638324]Notepad++ plugin when?[/QUOTE] sublime text*
[QUOTE=proboardslol;46637357]"Don't put multiple statements on a single line unless you have something to hide" -Linus Torvalds [sp]But Torvalds is kind of a cunt anyways[/sp][/QUOTE] its too idiomatic to not instantly recognize anyways get private set is pretty useful btw
If you don't have to execute any custom code when getting or setting the variable and when both getter and setter have to be public, i don't see why making it a property in the first place. A public variable would be just fine too. It's not like you can't change it later to a property if you really need to.
[QUOTE=cartman300;46639293]A public variable would be just fine too. It's not like you can't change it later to a property if you really need to.[/QUOTE] [URL="http://stackoverflow.com/a/12396331"]Actually, not always.[/URL]
[QUOTE=Sidneys1;46639397][URL="http://stackoverflow.com/a/12396331"]Actually, not always.[/URL][/QUOTE] And that's without mentioning the implications on say reflection.
[QUOTE=Sidneys1;46639397][URL="http://stackoverflow.com/a/12396331"]Actually, not always.[/URL][/QUOTE] Recompiling is a tiny cost, especially compared to a language like C++ where [I]any[/I] change is enough to force a recompile, and where compiling is slow.
[QUOTE=ECrownofFire;46639615]Recompiling is a tiny cost, especially compared to a language like C++ where [I]any[/I] change is enough to force a recompile, and where compiling is slow.[/QUOTE] Recompiling of any code that has your library as a dependency.
[QUOTE=MattJeanes;46638324]Notepad++ plugin when?[/QUOTE] I have a User-Defined Language file, but that's it. I am nowhere near confident enough in my C++ skills to write a plugin for it.
[QUOTE=Berkin;46640344]I have a User-Defined Language file, but that's it. I am nowhere near confident enough in my C++ skills to write a plugin for it.[/QUOTE] [url]http://sourceforge.net/projects/sourcecookifier/files/other%20plugins/NppPlugin.NET.v0.5.zip/download[/url]
[QUOTE=Map in a box;46640432][url]http://sourceforge.net/projects/sourcecookifier/files/other%20plugins/NppPlugin.NET.v0.5.zip/download[/url][/QUOTE] Looks interesting, I'll give it a go.
[QUOTE=Darwin226;46639854]Recompiling of any code that has your library as a dependency.[/QUOTE] Same argument applies.
Sorry, you need to Log In to post a reply to this thread.