The Big Programming Thread - Page 677
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
| ||
Acrofales
Spain17842 Posts
On November 16 2015 05:27 Cyx. wrote: I know a lot of C programmers who prefer
to
I used to really dislike assignments in conditionals too, but in this situation, it significantly reduces the typing and repetition necessary to manage the loop variable, so... I don't mind it at all now, especially since any decent C compiler will warn you if there's an un-bracketed assignment in a condition. Yeah. I don't mind assignment in a while loop as long as it is completely explicitly separate from the condition, as in the code sample you gave. It gets hairy when you assign and implicitly check for something that breaks out of the clause (such as assigning 0 to your variable). And in if statements it just plain always gets my hackles up. Assignments don't belong in if conditions. | ||
![]()
tofucake
Hyrule18969 Posts
On November 17 2015 05:06 WarSame wrote: What are your opinions on the best Javascript IDE? Writing it normally is kinda painful. I tried WebStorm and it looked good but it costs money. What are good free options? 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. | ||
Nyxisto
Germany6287 Posts
| ||
WarSame
Canada1950 Posts
| ||
Blitzkrieg0
United States13132 Posts
| ||
WarSame
Canada1950 Posts
| ||
TMG26
Portugal2017 Posts
On November 17 2015 05:06 WarSame wrote: What are your opinions on the best Javascript IDE? Writing it normally is kinda painful. I tried WebStorm and it looked good but it costs money. What are good free options? Not for me, i'm a student, YEAH! | ||
WarSame
Canada1950 Posts
| ||
Itsmedudeman
United States19229 Posts
| ||
Cyx.
Canada806 Posts
On November 17 2015 04:05 spinesheath wrote: I hope you treat warnings as errors then, though. Obviously the most important part is that you can't make these kinds of mistakes. If you have an automatic check in place that only allows 100% safe assignments then I guess that's fine. Well, I can't turn -Werror on at work but I never commit compiler warnings ![]() On November 16 2015 04:26 spinesheath wrote: Plus I usually don't go as low level as reading a file line by or character by character. I instead use a method that enumerates the lines or characters for me. I'm thinking C# here, but surely C can do similar things too. That was a bit of a simplified example - but googling 'strtok linux lxr' got me to http://lxr.free-electrons.com/source/arch/s390/hypfs/inode.c#L225 (after I learned that the Linux kernel actually uses a function called strsep() and not strtok()) which is a pretty solid example of this idiom in real-world C code. | ||
phar
United States1080 Posts
On November 17 2015 13:22 Itsmedudeman wrote: Is there a better way to write nested if statements? The && operator doesn't seem that good if I have multiple different conditions within an if statement. If I have like several nested conditions the code just looks.... off and it's not that easy to read at first glance. if (foo If you have too many conditions you may be approaching the problem in a convoluted way, try simplifying the amount of state you're holding. | ||
Itsmedudeman
United States19229 Posts
I could probably think of a better example where it just looks unreadable, but you get my point. | ||
Ropid
Germany3557 Posts
Some languages have "stuff" where you don't have to manually manage state of things like loops. That can then be composed together. Like, if your example is C#, you might want to look at LINQ and see if it can help you write it looking like
In Java 8 the lambda expressions together with streams do that. I assume C++ has a whole bunch of template libraries that do something similar. | ||
enigmaticcam
United States280 Posts
Anybody know of any resources out there that can help me? Maybe a book or something? My attempts at google have yielded limited results. | ||
Thaniri
1264 Posts
If all you're doing is form controls then you can write simple onclick events where if one box is checked then other html elements get checked/appear in the dom. You'd be using javascript to manipulate html element attributes in that case. | ||
WarSame
Canada1950 Posts
Thaniri is right about you overcomplicating it. That type of implementation in js is not that hard. If checking a check box makes all other check boxes in a set become checked, then use a list of that set of check boxes. When you need to check them all just loop through the list and check them one by one. | ||
Manit0u
Poland17187 Posts
On November 18 2015 02:54 enigmaticcam wrote: So I'll be starting a personal web project soon, all Microsoft .NET C# and ASP/MVC. Up until now, I've done very little javascript. But this project will have complex UI logic, things like if you check one box then these other boxes need to be enabled, etc. I want it to be as streamlined as possible for the user, so it feels like a lot of that UI work should be done on the client. But I've never really been able to close that gap between javascript and business rules wrapped in class objects. I don't want to just simply write some JS to do X. I'd rather write some type of dynamic layer that can interpret business rules and build the JS, so I don't have to rewrite a whole bunch of JS every time a rule changes. Anybody know of any resources out there that can help me? Maybe a book or something? My attempts at google have yielded limited results. You should really look into integrating AngularJS into your application then. It can handle all of the UI logic very well, works great with RESTful applications and can also improve UX and reduce server load if done correctly. On November 17 2015 18:12 Itsmedudeman wrote: I meant something that could look like
I could probably think of a better example where it just looks unreadable, but you get my point. Well, what you're describing here is pretty much the Arrow anti-pattern. The only way to combat it is structuring your code better. In the case above, you could separate that stuff into different function calls.
My C is pretty rusty, but I hope you catch the drift ![]() Edit: Obviously, my code is still pretty bad but way more vertical instead of horizontal. Instead of adding another block indentation you simply add another function to update your counters, which you keep in a struct somewhere and can access from other places too if required. It seems like more code, but it's actually way more managable since it's more compartmentalized. | ||
Cyanocyst
2222 Posts
Anyway my university requires significantly more math as pre-requisites for computer science, than it did for either of my majors. Is high level math directly needed to code at all? I understand that more math could probably sharpen your problem solving skills, and that could indirectly help your coding. Though wanting to know if it is directly related to any language. Also what is the easiest language to learn for a complete noob? I would like to try to teach my self some kind of coding just to see if it truly is something i'm interested in. Due to already having degrees, and not wanting to pay for more of them, no matter what, i'll probably never actually be good at this. Though maybe i could make a hobby out of it. | ||
solidbebe
Netherlands4921 Posts
On November 18 2015 04:15 Cyanocyst wrote: Hey guys, I have literally no coding experience at all. Disappointingly I graduated with degrees in Accounting and Finance last year. But i honestly hate both subjects. Anyway my university requires significantly more math as pre-requisites for computer science, than it did for either of my majors. Is high level math directly needed to code at all? I understand that more math could probably sharpen your problem solving skills, and that could indirectly help your coding. Though wanting to know if it is directly related to any language. Also what is the easiest language to learn for a complete noob? I would like to try to teach my self some kind of coding just to see if it truly is something i'm interested in. Due to already having degrees, and not wanting to pay for more of them, no matter what, i'll probably never actually be good at this. Though maybe i could make a hobby out of it. There are some programming jobs where you need to have strong math knowledge like games or cgi movies. I'd wager to say this is a very small percentage of programmers who end up in these kinds of fields though. For any other programming, you don't need anything more than basic arithmetic really. Good languages to start with I'd say python and java. They are high level so relatively easy to learn and very well supported ( many tutorials and such ). | ||
| ||