The Big Programming Thread - Page 679
Forum Index > General Forum |
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. | ||
WarSame
Canada1950 Posts
| ||
Itsmedudeman
United States19229 Posts
| ||
spinesheath
Germany8679 Posts
On November 19 2015 04:14 WarSame wrote: Si, senor. That's surprising. I was under the impression the large majority of SEs used C or C++. I suggest you look through a bunch of job offers of employers in your region and/or employers you'd like to work for and find out what languages they are hiring for. Job offers in the future (when you actually apply for one) might not ask for the same languages anymore, but there will always be an old code base that at least needs to be maintained. | ||
WarSame
Canada1950 Posts
| ||
Cyx.
Canada806 Posts
On November 18 2015 17:30 Manit0u wrote: Nice. Just out of curiosity, was my answer to him any good? I'd like for someone obviously more knowledgeable in C than me to give a comment on this little monster I've created. I really need to work my C-foo back up a bit ![]() http://www.teamliquid.net/forum/general/134491-the-big-programming-thread?page=677#13538 Well, I'll bite :D the only thing that's a little tricky in this is the Counters_{create,destroy} functions, and in my opinion using those at all here is a major no-no. You don't need to allocate the struct Counters on the heap, you're destroying it right away anyways - let the compiler do the work for you, put it on the stack. Then pass &counters to all Counters_test_* functions instead of counters. Also, your naming is pretty damn weird ![]() | ||
Itsmedudeman
United States19229 Posts
On November 19 2015 11:49 Cyx. wrote: Well, I'll bite :D the only thing that's a little tricky in this is the Counters_{create,destroy} functions, and in my opinion using those at all here is a major no-no. You don't need to allocate the struct Counters on the heap, you're destroying it right away anyways - let the compiler do the work for you, put it on the stack. Then pass &counters to all Counters_test_* functions instead of counters. Also, your naming is pretty damn weird ![]() The function names would throw me off a bit if I was reading that. The function is called test but it also increments a pointer value rather than returning anything. Also yeah, I'm working in C but I like the advice given. The only thing I'd change is wrapping the second code in an inc_time() function. | ||
Manit0u
Poland17341 Posts
![]() | ||
Deleted User 101379
4849 Posts
On November 19 2015 07:31 spinesheath wrote: I suggest you look through a bunch of job offers of employers in your region and/or employers you'd like to work for and find out what languages they are hiring for. Job offers in the future (when you actually apply for one) might not ask for the same languages anymore, but there will always be an old code base that at least needs to be maintained. That is definitely true. On the other hand, maintaining legacy code is hell. Fixing code you wrote 6 month ago yourself is already terrible, fixing code others wrote 6 years ago can kill you. | ||
![]()
tofucake
Hyrule19087 Posts
| ||
Manit0u
Poland17341 Posts
![]() | ||
spinesheath
Germany8679 Posts
On November 19 2015 22:00 Morfildur wrote: That is definitely true. On the other hand, maintaining legacy code is hell. Fixing code you wrote 6 month ago yourself is already terrible, fixing code others wrote 6 years ago can kill you. It's rare to get a job where you don't have to work with old code in one way or another. Better accept that possibilty and be prepared for it than ignoring it. | ||
Itsmedudeman
United States19229 Posts
| ||
spinesheath
Germany8679 Posts
On November 20 2015 02:47 Itsmedudeman wrote: Am I the only one who actually enjoys refactoring code? Every time I refactor my own code it feels like I just lost 100 pounds of weight. It does suck tho when it's just completely fucked up from the core and it's better to just rewrite it. I actually do like refactoring if I get the time to do it properly. Sadly that's usually not the case because stuff needs to get done. Rewriting legacy code (that is in use) from scratch is usually a bad idea beacuse by the time you're done rewriting you'll be faced with a huge amount of incompatabilities that stem from bugs in the legacy code (that have been worked around) AND your own code. It's better to develop a plan how to refactor the legacy code in small steps and then do those one by one. | ||
Nemphis
Belgium1 Post
On November 17 2015 05:46 tofucake wrote: At my company devs use a mix of Sublime (me and another guy), Atom (one guy), and something else (other guy on a different project). I personally love Sublime, and you can get some extensions to make autocompletes and code-aware upgrades. I personally really like atom, but if you want an editor for web-based stuff, you could give brackets a try. | ||
sabas123
Netherlands3122 Posts
On November 18 2015 22:35 Faust852 wrote: I was wondering, should I take a Client-Server type of approach, like the Server side is handling the Model-Controler type of things, and a second part, the Client, just handling the View and sending request to the Controler on the Server ? Yes this sounds good And is the networking part be handled by the Model, or by the Controler ? All the logic should be handled by controllers, models are just there to hold values. | ||
Faust852
Luxembourg4004 Posts
On November 20 2015 07:26 sabas123 wrote: Yes this sounds good All the logic should be handled by controllers, models are just there to hold values. Thank you ![]() | ||
phar
United States1080 Posts
On November 18 2015 17:30 Manit0u wrote: Nice. Just out of curiosity, was my answer to him any good? I'd like for someone obviously more knowledgeable in C than me to give a comment on this little monster I've created. I really need to work my C-foo back up a bit ![]() http://www.teamliquid.net/forum/general/134491-the-big-programming-thread?page=677#13538 Sorry I didn't see it earlier. Without more details then yea, generally breaking the incrementing out into smaller readable chunks helps. This isn't really a C-specific concern though, you'd find the same problem in Java, C++, etc. Idk about the other wrappers, my C is too rusty. I was just pointing out the fact that it looked like embedded timer code, and thus you might not actually need all those variables incremented every time. | ||
Acrofales
Spain18050 Posts
On November 20 2015 07:26 sabas123 wrote: Yes this sounds good All the logic should be handled by controllers, models are just there to hold values. In this case I agree, but in general, I would say that your model exists to abstract away from your values. If you store the time in milliseconds, but are only ever interested in whether it is morning, afternoon or night, that is "logic" that your model should do. Your model should provide the appropriate and necessary information. Often that's just passing on values, but it can require computation. | ||
Deleted User 3420
24492 Posts
In Java, an interface is a collection of methods that will be used by any class that implements the interface. | ||
Prillan
Sweden350 Posts
On November 22 2015 08:54 travis wrote: Is this an accurate statement: In Java, an interface is a collection of methods that will be used by any class that implements the interface. You're correct, if you mean "has to be implemented by" instead of "will be used by". I'd write something like: An interface is a collection of method signatures that has to be implemented in all classes that implement the interface. | ||
| ||