|
Thread Rules 1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution. 2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20) 3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible. 4. Use [code] tags to format code blocks. |
On April 01 2014 19:48 Manit0u wrote:Show nested quote +On April 01 2014 18:10 MichaelEU wrote:On April 01 2014 17:41 Manit0u wrote:On April 01 2014 16:36 icystorage wrote: im actually pissed reading that lol. im like "WHY WOULD YOU DELETE STUFF IN A CRITICAL MOMENT?!" I was working crazy hours and my brain didn't process stuff as intended... What happened to version control? There wasn't any. Didn't want to bother with doing it for such a small project that I was working alone with. Came back to bite me in the ass in the end.
I guess it made for a valuable lesson. 
If I imagine taking more than an hour for anything I git init.
|
put some time aside to get gcc-4.9.0 up and running with -std=c++1y. return type deduction with decltype(auto) seems very sweet.
|
On April 01 2014 23:21 nunez wrote: put some time aside to get gcc-4.9.0 up and running with -std=c++1y. return type deduction with decltype(auto) seems very sweet. I personally didn't understand the appeal with the somewhat strange syntax.
|
Woohoo! The test was passed. Need to put failsafes back into the app though.
Much weight. Such lift. Wow.
|
@rollin i think it's born out of necessity. they seem very hesitant to introduce new keywords. but i am not knowledgeable and easily confused, maybe i will get irked at a later point in time (just auto would be sweet). here's the rationale from the proposal:
Difference from decltype
Unfortunately, there is no way to get the effect of decltype with an auto return type; plain auto never deduces to a reference, and auto&& always deduces to a reference. This is a significant problem, as it means that forwarding functions can't use auto. We could consider using decltype semantics instead of the existing auto semantics, but that would mean giving different deduction semantics to auto depending on whether the declaration is of a variable or a function, and making auto functions different from lambdas.
Therefore, I propose to also allow decltype(auto) to get the decltype semantics without having to repeat the expression. For simplicity of specification and orthogonality I propose to allow it everywhere that plain auto is allowed, except for introducing a trailing-return-type. It occurs to me that the difference in meaning of decltype depending on the form of the expression (e.g. parenthesized or not) might be more surprising in this context, but I think it would be even more surprising if this worked differently from C++11 decltype. src
@manitou $
i wonder if it would be possible to get type deduction for initializing of static variables too...
|
Damn, it's so irksome when you're doing something based on strings (like assigning value of one string to the other) and then you discover that string can return "string", "" or 0, the latter resulting with fatal error because something was expecting a string and it got an int.
Also, a pop quiz for all of you (regarding my latest headaches): What do you get when you try to invoke line[0] on an empty line?
|
On April 01 2014 06:18 Cyx. wrote:Show nested quote +On April 01 2014 03:52 spinesheath wrote: As I said, I find the C/C++ version harder to read too, but it provides that little extra safety against typos. In languages like C# where you don't have the stupid implicit pointer to bool cast, you don't need it. Or you could compile with warnings as errors, then you get the best of both worlds - compiler error when you typo, and you don't have to make your code awkward to read ^^ Warnings as errors is always on, that's not even up for discussion. Max warning level as well. So yeah, it's not really necessary to use the proper C/C++ style. But you can never have enough safety nets in those languages.
And I sure hope that macro stuff is actual C. Makes me shudder.
|
I'm looking for recommended books and articles on learning C# and .NET from scratch, anybody have anything they would suggest?
|
Other than the MSDN overview?
Use WPF instead of WinForm.
|
I found C# fairly easy to pick up. Basically I just started a project and googled as questions came up. I had a decent amount of C++ experience, but still I don't think it should be too hard just from the internet (Stackoverflow + MSDN). General good OOP practices are what you should be most concerned about, the rest is easy with C#.
WPF has a fairly steep learning curve, but is well worth it.
|
I'm using GTK# since I mostly work under Linux.
And as far as books go this one is fine: http://shop.oreilly.com/product/0636920024064.do
I'm constantly using docs found on MSDN, dotnetperls.com etc. but I've found a long time ago that nothing really beats a good book on the subject. Especially that books are easier to learn from and remember what you learn (the way our brain works with roadmaps and all, e-books and Internet articles simply don't give you that).
|
My main problem with books is that you can't CTRL+F through them, and I don't really have the time nor need to go step-by-step through any textbook. Maybe if you have a lot more time on your hands then they would be useful, but online references have usually been good. A pdf version of the book would be better too, but I don't absolutely buy the idea that books are easier to learn from unless you're actually going through the book page by page.
|
Guess I'll slowly work through MSDN and stuff.
Need help with a SQL query, trying to update 2 columns on rows in a table that match a certain criteria. Assuming I have a userid column that starts with '13%', and I want to change every userid that starts like that to '14%'...so something like
13Fawkes would be turned into 14Fawkes, is this possible?
mySQL
update 'tablename' set 'user_id' = CONCAT('14', SUBSTRING('user_id', 3)), 'user_id_clone' = CONCAT('14', SUBSTRING('user_id', 3)) where 'user_id' LIKE '13%'
Would this work?
|
Murach C# is a good introduction and has exercises, but not very hard ones. There is also Essential C#, Manning C# in Depth and others for more indepth features.
I like C# a lot and often the problem is simply that you didnt know about a technique or a .net class that solves all issues you had 
Also, what do you guys think is the most elegant way to pop a messagebox/new form, pause execution of the main program and meanwhile send and read data from a USB port, while in the mainform if possible a "cancel" button should still be active. Once something specific is read on USB, messagebox goes away and the program continues.
Im not good with all this multithreading. TT
|
On April 04 2014 01:47 Blisse wrote: My main problem with books is that you can't CTRL+F through them, and I don't really have the time nor need to go step-by-step through any textbook. Maybe if you have a lot more time on your hands then they would be useful, but online references have usually been good. A pdf version of the book would be better too, but I don't absolutely buy the idea that books are easier to learn from unless you're actually going through the book page by page.
That's why you have numerous indexes in the book, you can search through them too, you just have to know how 
Also, it's easier to learn from a book because it's a physical object that gives you more references to the information you seek. Stuff you don't normally notice, like how far it is from the beginning/end of the book judging by how much paper you feel under your fingers, where is it located on the page etc. That's how our brain memorizes stuff.
As an example: It is easier to learn about numerous characters in the book, their names, appearance, history etc. than it is to memorize a 30 digit number even though the amount of data is vastly greater in the first case. It's all because of this roadmaps with waypoints that your brain creates when reading an actual book. That's also why in the memory-enhancing classes they teach you to make stories when you have to memorize something so that instead of having to commit a long number to the memory you remember stuff like 5 elephants bought 3 apples but monkeys stole 2 of them and sold them for 4 pennies. Even though at first it seems that memorizing a story is harder since it's more data it's actually easier for your brain to process because that's how it's built.
You don't necessarily have to read through the entire textbook too. Just pick it up if you need something, go through the index and try to find it. If you ever need that info again you'll be surprised how fast you can find it again (usually even faster than searching on the net). The added benefit is that after you read it in the book there's a greater chance that it'll stay with you and you won't have to look for it again.
|
I've been reading a bit of that "Clean Code" book. One of the suggestions is not to return null but to throw an exception or return a special case object. Is that how you guys do it as well? I've recently got annoyed at some bits of my code that are if (object == null). 
But then, do you have to catch those exceptions? Can't they go silently like "return" in a void method? What about int/boolean methods though? "return" is insufficient there, but if you write "return -1", then whether you check for (object == null) or (object != -1) kind of has the same purpose.
|
On April 04 2014 09:53 darkness wrote:I've been reading a bit of that "Clean Code" book. One of the suggestions is not to return null but to throw an exception or return a special case object. Is that how you guys do it as well? I've recently got annoyed at some bits of my code that are if (object == null).  But then, do you have to catch those exceptions? Can't they go silently like "return" in a void method? What about int/boolean methods though? "return" is insufficient there, but if you write "return -1", then whether you check for (object == null) or (object != -1) kind of has the same purpose.
Returning null can be appropriate in some cases, raising an exception in others, it depends on context. If you're code is going to break if the return value is null then it should throw an exception plain and simple. Things get a bit more complicated with accessor methods in some situations, recent example I ran into was an accessor method for a signed cookie. If it successfully unsigns the cookie then it will return the value, otherwise it will return nil (which could be caused by bad cookie value or no cookie at all). This creates a clean encapsulation for accessing the signed cookie values that is easy to test. An example of a situation where returning nil could be a problem: you have a object being assigned through a function, and then a method being invoked on that object. If the object returns nil the method call will cause an exception. Better to have it blow up at the source rather than somewhere down the chain.
|
On April 04 2014 06:44 Fawkes wrote:Guess I'll slowly work through MSDN and stuff. Need help with a SQL query, trying to update 2 columns on rows in a table that match a certain criteria. Assuming I have a userid column that starts with '13%', and I want to change every userid that starts like that to '14%'...so something like 13Fawkes would be turned into 14Fawkes, is this possible? mySQL
update 'tablename' set 'user_id' = CONCAT('14', SUBSTRING('user_id', 3)), 'user_id_clone' = CONCAT('14', SUBSTRING('user_id', 3)) where 'user_id' LIKE '13%'
Would this work? Why do you have a user_id_clone column? Is it always a clone? (if it's not then your where clause will muck things up) If you want to do regex replaces: https://github.com/mysqludf/lib_mysqludf_preg#readme
I don't have mysql installed on this box but it does look like that would work.
I am concerned as to why you would ever want to do this ever like seriously what is going on here.
|
On April 04 2014 09:22 Manit0u wrote:Show nested quote +On April 04 2014 01:47 Blisse wrote: My main problem with books is that you can't CTRL+F through them, and I don't really have the time nor need to go step-by-step through any textbook. Maybe if you have a lot more time on your hands then they would be useful, but online references have usually been good. A pdf version of the book would be better too, but I don't absolutely buy the idea that books are easier to learn from unless you're actually going through the book page by page. That's why you have numerous indexes in the book, you can search through them too, you just have to know how  Also, it's easier to learn from a book because it's a physical object that gives you more references to the information you seek. Stuff you don't normally notice, like how far it is from the beginning/end of the book judging by how much paper you feel under your fingers, where is it located on the page etc. That's how our brain memorizes stuff. As an example: It is easier to learn about numerous characters in the book, their names, appearance, history etc. than it is to memorize a 30 digit number even though the amount of data is vastly greater in the first case. It's all because of this roadmaps with waypoints that your brain creates when reading an actual book. That's also why in the memory-enhancing classes they teach you to make stories when you have to memorize something so that instead of having to commit a long number to the memory you remember stuff like 5 elephants bought 3 apples but monkeys stole 2 of them and sold them for 4 pennies. Even though at first it seems that memorizing a story is harder since it's more data it's actually easier for your brain to process because that's how it's built. You don't necessarily have to read through the entire textbook too. Just pick it up if you need something, go through the index and try to find it. If you ever need that info again you'll be surprised how fast you can find it again (usually even faster than searching on the net). The added benefit is that after you read it in the book there's a greater chance that it'll stay with you and you won't have to look for it again.
You can find memory hookes when reading on a computer just as well as with a physical book. Groupings of paragraphs on the page, line numbers, etc... All that being said memorization isn't very valuable when it comes to programming. You shouldn't have to rely on memorization techniques for your understanding of data structures and algorithms, and the things that are handy to have memorized can be looked up in a few seconds on a computer and eventually will be memorized if you use them enough. (And if you don't, then they weren't worth the effort to memorize.)
|
On April 04 2014 13:17 CatNzHat wrote:Show nested quote +On April 04 2014 09:53 darkness wrote:I've been reading a bit of that "Clean Code" book. One of the suggestions is not to return null but to throw an exception or return a special case object. Is that how you guys do it as well? I've recently got annoyed at some bits of my code that are if (object == null).  But then, do you have to catch those exceptions? Can't they go silently like "return" in a void method? What about int/boolean methods though? "return" is insufficient there, but if you write "return -1", then whether you check for (object == null) or (object != -1) kind of has the same purpose. recent example I ran into was an accessor method for a signed cookie. If it successfully unsigns the cookie then it will return the value, otherwise it will return nil (which could be caused by bad cookie value or no cookie at all). This creates a clean encapsulation for accessing the signed cookie values that is easy to test.
In cases like these you can consider using Optional<T> instead of @Nullable T.
|
|
|
|
|
|