The Big Programming Thread - Page 83
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. | ||
RoyGBiv_13
United States1275 Posts
| ||
nath
United States1788 Posts
On October 04 2011 05:12 Thorakh wrote: I always hear people talking about this, but what do you exactly mean by that? Can you give any examples? they solve the problem given to them, not accounting for the fact that new problems or requirements surface in the future, providing programmers with endless amounts of work to update/tweak things. fundamental programming principles is what is lacking in 95%; scalability and long-term coding practices rather than quick fixes and script-kiddie-esque solutions. i agree with Mordiford; programmers are born. been coding since i was 7 (dad is a crazy physics guy and taught me BASIC at that age). been in the IT industry without a degree and doing well, including running my own business ![]() | ||
EvanED
United States111 Posts
On October 04 2011 02:36 heishe wrote: You kinda cut off the point of my statement. I know that you learn some things there that you'll need later, but I think nothing that you learn in one of those courses can't be picked up a lot quicker by reading a tutorial or a good book. Or can you provide a counter example? I don't think that is much more true of programming than any other topic. If anything, the fact that it's not as well-developed (and "general cases of problems which can be solved with general methods" if you believe that -- I only sort of buy it) means that the ability to ask questions and such is more important than it is in many other topics. And tutorials and books don't answer questions. (To disclaim my bias, I'm sort of aiming to be a CS prof in a couple years.) | ||
mmp
United States2130 Posts
On October 04 2011 05:22 vyyye wrote: Slightly retarded question, but how do you navigate the Java API? I opened it a bunch of times, I'm met with a box with links and some stuff on the sidebar, but I have no idea how or where I should look for anything. Tried clicking about but not getting wiser. I'm really new to programming as a whole, maybe that's why? Used a For Dummies book a bit which kept advising to look X up in the API and eh, not quite working out. We can certainly help point you in the right direction, but maybe you should explain what it is you're trying to do? If you're talking about the standard API, then yeah there's a lot there but it should be manageable once you've articulated what task you're trying to achieve. e.g. I want open a network socket and talk with a server... so I go into the java.net package (sounds like the right one) and WOW everything I could need is right there. So I click on class Socket, and I get a huge list of members and other information. Questions that come to mind are: (1) Am I in the right place? (2) Is this the right class? (3) How do I use this class? (1) The description at the top tells me that it's probably what I'm looking for. (2) I can also see that it extends Object (if it had any siblings worth considering, I would probably see an abstract base class that it inherits from). It implements Closable, which doesn't appear to be very interesting, and it has one documented subclass SSLSocket -- which does what its name says. So I've probably got the right class unless I want to use SSL. (3) Ok, the only way I can use this class is to instantiate it with one of its many constructors. *read read read* Ok, I see some redundancy in the constructors, but I think I'm going to need to specify a port and address if nothing else. The rest is checking out what the methods do, and how to read/write. Welcome to JavaDocs. It's not very friendly at first, but in time you'll find it is both clean and organized. It's obviously nowhere near as user-friendly as, say, the Python docs (which are generally more elaborate and include generous amounts of example code), but it's usually simpler to navigate and more thorough than hand-written docs (which often forget to mention important details). | ||
vyyye
Sweden3917 Posts
On October 04 2011 06:01 mmp wrote: We can certainly help point you in the right direction, but maybe you should explain what it is you're trying to do? If you're talking about the standard API, then yeah there's a lot there but it should be manageable once you've articulated what task you're trying to achieve. e.g. I want open a network socket and talk with a server... so I go into the java.net package (sounds like the right one) and WOW everything I could need is right there. So I click on class Socket, and I get a huge list of members and other information. Questions that come to mind are: (1) Am I in the right place? (2) Is this the right class? (3) How do I use this class? (1) The description at the top tells me that it's probably what I'm looking for. (2) I can also see that it extends Object (if it had any siblings worth considering, I would probably see an abstract base class that it inherits from). It implements Closable, which doesn't appear to be very interesting, and it has one documented subclass SSLSocket -- which does what its name says. So I've probably got the right class unless I want to use SSL. (3) Ok, the only way I can use this class is to instantiate it with one of its many constructors. *read read read* Ok, I see some redundancy in the constructors, but I think I'm going to need to specify a port and address if nothing else. The rest is checking out what the methods do, and how to read/write. Welcome to JavaDocs. It's not very friendly at first, but in time you'll find it is both clean and organized. It's obviously nowhere near as user-friendly as, say, the Python docs (which are generally more elaborate and include generous amounts of example code), but it's usually simpler to navigate and more thorough than hand-written docs (which often forget to mention important details). Ah, thanks a ton! It seems I haven't even looked in the right place, let alone found it. I have been looking at the Documentation page thinking that was what the book/folks were referring to, oh well. The actual API isn't at all the nightmare I thought it was, damn that makes life easier. I do wonder how retarded this will seem in a few months looking back in hindsight, ahh. | ||
Millitron
United States2611 Posts
On October 04 2011 05:12 Thorakh wrote: I always hear people talking about this, but what do you exactly mean by that? Can you give any examples? Most people are bad about commenting there work, and even when they do, the comments aren't very explanatory. Further, maintainable code needs commonly used variables defined globally, rather than each time its needed, so you can update it in only one spot and be done with it. Last, variables should be well-named. Unless it's some loop-control variable you'll never use again, you should never name things with a single character. Always use more descriptive names. | ||
haduken
Australia8267 Posts
On October 04 2011 09:24 Millitron wrote: Most people are bad about commenting there work, and even when they do, the comments aren't very explanatory. Further, maintainable code needs commonly used variables defined globally, rather than each time its needed, so you can update it in only one spot and be done with it. Last, variables should be well-named. Unless it's some loop-control variable you'll never use again, you should never name things with a single character. Always use more descriptive names. The best code is the one that speaks for itself either via convention or a well known architectural design this way even without comments a new coder can immediately recognize the program flow and do work on it however as we all know this is difficult to achieve especially with the resource and time constraints that most projects have. | ||
Nanar
United States16 Posts
| ||
alwinuz
Netherlands77 Posts
On October 03 2011 23:26 EvanED wrote: They provide a partial implementation. It might be easier to understand that by looking at AbstractCollection.If you have some new idea for a collection, you can extend AbstractCollection instead of implementing Collection and do way less work. For full functionality, the only functions you need to write are add(E obj), iterator(), and size(). That's three functions instead of the 15 of the Collection interface. The AbstractCollection will do things like provide contains(Object o) by calling iterator() and walking over the collection for you. You are, of course, free to override more of those methods if you have a better implementation. Yeah I see, I got puzzeled by the remark "doesn't specify how the implementation works". In my mind "implementation is up to you" --> interface. Of course an abstract base class is useful for writing your own collection. | ||
Deleted User 101379
4849 Posts
On October 04 2011 05:12 Thorakh wrote: I always hear people talking about this, but what do you exactly mean by that? Can you give any examples? Ok, as example of code that studied programmers created in this company. Some of the stuff is replaced/fixed, other parts are still active: (Bolded text added by me) + Show Spoiler [Version Control] + -rw-r--r-- 1 www www 27947 Jan 3 2007 28May03.mov_func.inc.phtml -rw-r--r-- 1 www www 98923 Sep 21 2010 mov_func.inc.phtml -rw-r--r-- 1 www www 47372 Jan 3 2007 mov_func.inc.phtml~ -rw-r--r-- 1 www www 98861 Sep 21 2010 mov_func.inc.phtml.20100921 -rw-r--r-- 1 www www 84133 Aug 23 2007 mov_func.inc.phtml.BAK -rw-r--r-- 1 www www 88870 Oct 9 2007 mov_func.inc.phtml.desaster ??? -rw-r--r-- 1 www www 88766 Aug 24 2007 mov_func.inc.phtml.NEW -rw-r--r-- 1 www www 73230 Jun 5 2007 mov_func.inc.phtml.ol10 -rw-r--r-- 1 www www 47374 Jan 3 2007 mov_func.inc.phtml.ol3 -rw-r--r-- 1 www www 97245 Dec 10 2009 mov_func.inc.phtml.ol5 -rw-r--r-- 1 www www 48334 Jan 3 2007 mov_func.inc.phtml.ol6 -rw-r--r-- 1 www www 48665 Jan 3 2007 mov_func.inc.phtml.ol7 -rw-r--r-- 1 www www 57774 Jan 4 2007 mov_func.inc.phtml.ol8 -rw-r--r-- 1 www www 59815 Apr 24 2007 mov_func.inc.phtml.ol9 -rw-r--r-- 1 www www 49476 Jan 3 2007 mov_func.inc.phtml.old -rw-r--r-- 1 www www 45118 Jan 3 2007 mov_func.inc.phtml.old2 -rw-r--r-- 1 www www 88870 Nov 27 2007 mov_func.inc.phtml.on -rw-r--r-- 1 www www 80994 Aug 14 2007 mov_func.inc.phtml.on.php -rw-r--r-- 1 www www 84775 Aug 23 2007 mov_func.inc.phtml.tmp -rw-r--r-- 1 www www 86113 Aug 23 2007 mov_func.inc.phtml.tmp2 + Show Spoiler [Global Variables] + function include_skin($skinfile) { global $template, $scn, $sea, $lng, $sub, $VC_SESSION_C, $off, $aff; global $allowedxyzewrlhjth3w45z; // Achtung NICHT löschen oder modifizieren English: Attention. DON'T delete or modify global $stm, $PHP_SELF, $mov, $sfm, $psb, $act, $key, $lang, $fn, $fe, $rn, $re; global $REMOTE_ADDR, $HTTP_USER_AGENT, $niz, $mid, $cards_key, $fra, $spe; ... } This was NOT an exception but the standard (also: register_globals on). At least most other functions were a little more sane... though not by much function cards_pay() { global $mid, $fe, $fn, $rn, $re, $scn, $key, $niz, $stm, $REMOTE_ADDR, $HTTP_USER_AGENT; ... } + Show Spoiler [Simple SQL Queries] + This is one of the shorter ones, luckily just from the cron which runs only once per day but takes 45-60 minutes. I wrote a replacement prototype with a new DB layout that took 5 minutes, though due to time constraints i can't switch the page to the new Database. The queries from the page itself don't look a lot better though. INSERT INTO movieon4.tmp_movie_detail SELECT m.movie_id, t3.producer_id, t3.producer, m.director, m.produced_year, m.barcode, GROUP_CONCAT(DISTINCT IF(p.propertytype_id = 14,p.property_id,NULL),'|',p.property_text_id,'|',IFNULL(tct.main_category_id,0),'|',IFNULL(p2.property_text_id,0) SEPARATOR ',') AS movie_category, ROUND((IFNULL(CAST(GROUP_CONCAT(DISTINCT CASE p.property_id WHEN 43 THEN 1 WHEN 44 THEN 2 WHEN 45 THEN 3 WHEN 46 THEN 4 WHEN 47 THEN 5 END SEPARATOR '') AS decimal),4))) AS sterne, GROUP_CONCAT(DISTINCT IF(p.propertytype_id = 24,p.property_text_id,NULL)) AS sprache, GROUP_CONCAT(DISTINCT p.property_id SEPARATOR ',') REGEXP '^74,|,74,', GROUP_CONCAT(DISTINCT a.actor_id,'|',a.actor SEPARATOR ','), GROUP_CONCAT(DISTINCT IF(p.propertytype_id = 34,p.property_id,NULL)), GROUP_CONCAT(DISTINCT IF(p.propertytype_id = 34,p.property_text_id,NULL)), IFNULL(vs.sum,0), m.aspect_ratio FROM (SELECT DISTINCT movie_id FROM movieon4.tmp_movie WHERE type = 0) tm LEFT JOIN moviedb.movie m ON m.movie_id = tm.movie_id LEFT JOIN moviedb.producer t3 ON t3.producer_id = m.producer_id AND t3.deleted = 0 AND t3.product_id != 5 LEFT JOIN moviedb.movieproperty mpp ON tm.movie_id = mpp.movie_id AND mpp.property_id IN (SELECT DISTINCT property_id FROM moviedb.productproperty WHERE product_id IN ( 1, 6, 8, 9, 16, 17, 18, 19, 22 )) LEFT JOIN moviedb.property p ON p.property_id = mpp.property_id AND p.deleted = 0 LEFT JOIN movieon4.tmp_vote_statistic vs ON tm.movie_id = vs.movie_id LEFT JOIN movieon4.tmp_category_tree tct ON tct.category_id = p.property_id LEFT JOIN moviedb.property p2 ON p2.property_id = tct.main_category_id AND p2.deleted = 0 LEFT JOIN moviedb.actormovie am ON am.movie_id = tm.movie_id LEFT JOIN moviedb.actor a ON a.actor_id = am.actor_id AND a.deleted = 0 WHERE 1 AND p.propertytype_id in( 14,17,22,23,24,34) GROUP BY m.movie_id + Show Spoiler [Common If Pattern] + if ($something) { // Nothing here } else { // Do stuff } Also: - 30'000 lines of code in one of the sub projects without a single function - The same SQL Query repeated 13 times in a single 1000 line code file (though in one instance the table aliases t1 and t2 were switched around) - Database columns with a comma seperated list of pipe seperated values... The only way to search in this field are regex... and it's a common search field, so all queries are horribly slow. - All functions are in a single file called "funcs.php". At least we go rid of "somethings.php" in most of the projects (no joke). - Table and column names sometimes english, sometimes german, sometimes misspelled even in a single table/database. ID columns sometimes "id", "xyz_id" or just "xyz", even for the same ID in different tables. In the time here i tried to start several initiatives to improve the code quality: - Started a company library of programming books (work related and not work related) and bought a lot of books from my own money for everyone else to read because they company didn't want to spend money on training. I wanted to give the other programmers a chance to train themselves. Every other programmer said "Hey, cool idea"... Only 2 of them have actually read some the books. - Code Reviews - cancelled, the others didn't find it useful. - Seperated Testing department - cancelled, the company hired a student that just clicked through the frontend and never found any errors. - Unit Testing - not implemented, "takes too much time" Anyone wondering why i'm quitting? PS: Anyone looking for a programmer that is burnt out from having to deal with horrible programmers? | ||
renox
United States48 Posts
I'm currently a first year computer science student and I am in need of a job. What would you guys suggest I look for to benefit me in this field? Is there anything that I would even qualify for just being a first year student? Any and all advice would be lovely, share personal experiences of working during school etc. | ||
![]()
tofucake
Hyrule18969 Posts
Is this going to be a job you do for school (co-op program) or just something you'll do in your spare time? | ||
Deadeight
United Kingdom1629 Posts
How does python compare to other languages? Is it relevant/commonly used? Is it similar? It's actually quite fun. | ||
renox
United States48 Posts
On October 05 2011 07:18 tofucake wrote: Almost any work you'll get as a first year student will be bitch work and there's no way around it. Is this going to be a job you do for school (co-op program) or just something you'll do in your spare time? Well I need a job just to have money and for my expenses, but I was wondering if there was something I could do that would later be useful to me in some way in regards to this field. So I was wondering if you guys have had some luck like this or experience with it. I mean I could get some random job like most college students but I figured if I could tie it into the field I want to study somehow it would benefit me because I may find it interesting but also be an asset to my career down the road. | ||
WickedSkies
Netherlands81 Posts
On October 05 2011 07:28 Deadeight wrote: I do physics and maths at uni, and I'm currently doing a python module in which the aim is to model high energy particle collisions. The basics are really dull, but it gets pretty interesting, and I've ended up downloading python at home and using the skype module and stuff. How does python compare to other languages? Is it relevant/commonly used? Is it similar? It's actually quite fun. Despite the fact that I am a hardcore Java programmer, I am somewhat also familiar with Python, so here it goes Well, Python is a somewhat unique language in the sense it uses indentation not only for readability. As far as I know, there is no other similar programming language in that regard, but I might be wrong. Usually I use Python for scripting, but as I am a simpleton and I suck at Python (the syntax, man, the syntax), I prefer bash/Perl for scripting tasks. Don't be fooled by my above statement, though, Python is by no extent merely a scripting language, although in my encounters with it I have used it as such I hear it is a pretty decent programming language and you can do a lot of stuff with it. As with almost every Interpreted language (that is a no-compiler language), you don't have to wait much in development, it's just a matter of saving the file and running it. I am not familiar with the algorithms of garbage collection or reference counting as I am familiar with the garbage collectors in Java, but I assume there are books for that. Also, Python code seems to be shorter in length (but wider, unfortunately) than its equivalent in bash or Perl. For me, Python is actually the least readable programming language I have ever encountered in my life (at least it's not much lines), but my colleagues find it easy to read, so let's just say I am biased in that regard. There are interpreters for almost every architecture you can come up with, so it is pretty much available anywhere. On the job market, I have not seen much vacancies for Python programmers, as it is not very popular as a main programming language nowadays, but there are some indeed, and also it is a big plus to have on your resume together with some other like c,c++, Java, C# or some other stuff. Hope my ramblings have been helpful or a tad informative to you. | ||
EvanED
United States111 Posts
On October 05 2011 08:43 WickedSkies wrote: Despite the fact that I am a hardcore Java programmer, I am somewhat also familiar with Python, so here it goes Well, Python is a somewhat unique language in the sense it uses indentation not only for readability. As far as I know, there is no other similar programming language in that regard, but I might be wrong. Haskell almost does. (It has optional braces, but they seem to be rarely used, and the indentation guides what basically amounts to automatic brace placement in places you don't use them explicitly.) Usually I use Python for scripting, but as I am a simpleton and I suck at Python (the syntax, man, the syntax), I prefer bash/Perl for scripting tasks. There's no accounting for taste I guess. :-) I am not familiar with the algorithms of garbage collection or reference counting as I am familiar with the garbage collectors in Java They're... lacking. The evidence I've seen suggests that good generational garbage collectors (e.g. what's in the JVM) should perform better than reference counting (especially reference counting with occasional walks of the object graph to deal with cycles), albeit at the cost of a rather larger memory use. For me, Python is actually the least readable programming language I have ever encountered in my life (at least it's not much lines), but my colleagues find it easy to read, so let's just say I am biased in that regard. I'm sure this is almost entirely familiarity. I would put it far above Bash for instance, and above Perl. On the job market, I have not seen much vacancies for Python programmers, as it is not very popular as a main programming language nowadays, but there are some indeed, and also it is a big plus to have on your resume together with some other like c,c++, Java, C# or some other stuff. On the other hand, while there may not be all that many "Python" jobs out there, there are a ton of jobs where you are likely to use Python. For lots of companies, even if their primary dev language is C++ or Java or whatever, they'll have a bunch of Python scripts hanging around to do various tasks. Work as glue between components, have as a build system (SCons for instance is gaining traction, and SCons build scripts are written in Python; there's also the lesser-known Waf), a configuration language (Buildbot), etc. So if you were to apply to such a company, having some Python knowledge could very easily be a definite plus. Google also does a crapload of programming in Python. | ||
Beatrenger
Mexico22 Posts
| ||
Deleted User 101379
4849 Posts
On October 06 2011 09:58 Beatrenger wrote: OK.. so i downloaded Netbeans and it works fine and all but i have a HUGE problem with the loop FOR thingy... I don't want to type the code here but everything seems to be fine cause its not sending me any error but net-beans is not reading at all the for cycle it goes straight to the end and prints the initial number i set for some variable in the beginning. can i pm the code to someone or something the code is rather short like 5 lines its for adding numbers... Why not just post it here if it's short? Or if it's longer, just put it into spoiler tags. | ||
MisterD
Germany1338 Posts
![]() | ||
Frigo
Hungary1023 Posts
I want it to use in a graph library. Graph is Observable, NodeVector and EdgeVector are vectors indexed by the id of Node and Edge objects, and they automatically grow when new nodes or edges are added to the graph. At the moment I am using a custom Observable and Observer class, but it would be much tidier if I used the standard classes. However if they increase the runtime from O(n log n) to O(n^2) it is out of the question. A demonstration of the current version: DirectedGraph G = new DirectedSetGraph(); | ||
| ||