Slashdot Mirror


Reuse Code Or Code It Yourself?

eldavojohn writes "I began coding for a project that had simple requirements for my employer — Web services and a test application for them. But requirements have been creeping, as they always do. Initially I had decided to use the Spring Framework with Hibernate. And I re-used a lot of libraries that made things simple and quick for me. The new requests coming in involve capabilities beyond those of the frameworks. Now, I used to be told that good programmers write code and great programmers reuse code. It's starting to look like I would have saved myself a whole lot of time if I had written the database transaction using JDBC instead of Hibernate — now that I'm married to this object model framework, some of this stuff doesn't look doable. So what is better for the majority of software projects out there: reuse code, or code from scratch? What elements or characteristics of a problem point to one option over the other?"

429 comments

  1. It's knowing when by Bender0x7D1 · · Score: 5, Insightful

    It's not rewriting code or reusing code that makes you a great programmer. It's knowing when to rewrite code and when to reuse code that makes you a great programmer.

    --
    Reading code is like reading the dictionary - you have to read half of it before you can go back and understand it.
    1. Re:It's knowing when by Midnight+Thunder · · Score: 4, Interesting

      It's not rewriting code or reusing code that makes you a great programmer. It's knowing when to rewrite code and when to reuse code that makes you a great programmer.

      Exactly. Experience will help you with this.

      You can reuse, reuse or rewrite:
        - the first case is trying to make the best of what you have and building on that
        - the second case is finding a library that already does what you are wanting to do
        - finally you take the time to rewrite things yourself

      Laziness is not a bad trait, since this will sometimes help you decide where you are best spending your energy. The bar is a good answer, but not applicable in this scenario ;)

      --
      Jumpstart the tartan drive.
    2. Re:It's knowing when by Anonymous Coward · · Score: 0

      It's not rewriting code or reusing code that makes you a great programmer. It's knowing when to rewrite code and when to reuse code that makes you a great programmer.

      Aphorisms are the best way to get modded up on Slashdot.

    3. Re:It's knowing when by syousef · · Score: 5, Insightful

      It's not rewriting code or reusing code that makes you a great programmer. It's knowing when to rewrite code and when to reuse code that makes you a great programmer.

      Actually it's all of the above and more...a great programmer can:
      1) Evaluate the suitability of existing code for the task
      2) Use the existing code appropriately
      3) Write excellent readable, maintainable code when needed (and only when needed) to fill the gaps
      4) Communicate well with the business to understand the problem and design a solution

      Each of the above skills you're missing decreases your chances of success.

      --
      These posts express my own personal views, not those of my employer
    4. Re:It's knowing when by bky1701 · · Score: 2, Interesting

      In my book, it is outputting code that works well and is maintainable that makes a good programmer.

    5. Re:It's knowing when by magarity · · Score: 1

      In my book, it is outputting code that works well and is maintainable that makes a good programmer
       
      That's a little too simplistic, isn't it? What good is code that works well and is maintainable if the system it runs on has become obsolete? Development time must be taken into account as well and that's where the whole reuse vs from scratch really comes into play.

    6. Re:It's knowing when by Artraze · · Score: 5, Insightful

      > - the first case is trying to make the best of what you have and building on that

      To add to this, never ever simply "reuse" code; if you just copy and paste you'll end up with a horribly designed hack job worth of TDWTF. Instead, take what you have and massage it into place.

      In this particular case, it sounds like your design no longer hashes well with the requirements. My suggestion is to start rewriting/reworking isolated portions of the code base and create a temporary compatibility layer (if necessary) to interface with the old code. Continue doing this until the entire application is converted over to the new design.

    7. Re:It's knowing when by DiegoBravo · · Score: 1

      Nah..... just go beyond that silly traditional dichotomy by consistently applying eXtreme programming, so you will never need to know if you're reutilizing or recoding... you're just eXtreme programming your never ending requirements.

    8. Re:It's knowing when by Anonymous Coward · · Score: 0

      Being first at it doesn't hurt either. Of course that would just make you bad ass! Woof!

    9. Re:It's knowing when by ClosedSource · · Score: 5, Insightful

      Well, I think the GP has a point. These days there seems to be more focus on worrying about the future than producing a high-quality product today (where quality means the least buggy product). Often you spend a lot of time creating sophisticated abstractions to ease future extensions only to find that the future is so different than you expect that your elegant architecture is just code bloat.

    10. Re:It's knowing when by ArmyOfAardvarks · · Score: 1

      My attitude is generally, if rewriting is manageable, do it. You'll have a better fit for you r App. If rewriting isn't manageable, then reuse, but do so carefully. Taking on a project that's too big sucks, but when someone else's code doesn't wok correctly, have fun debugging it.

    11. Re:It's knowing when by Anonymous Coward · · Score: 0

      I should add:
      5) Identificate parts likely to change.

    12. Re:It's knowing when by Anonymous Coward · · Score: 5, Insightful

      You left out
      5) Say No when appropriate

    13. Re:It's knowing when by SL+Baur · · Score: 1

      It's not rewriting code or reusing code that makes you a great programmer. It's knowing when to rewrite code and when to reuse code that makes you a great programmer.

      Exactly. Experience will help you with this.

      Well ... yes and no. It's not exactly "rewriting" code if you have to duplicate the functionality of a library for a superset of the capability if the library doesn't fit the requirements.

      Certainly, experience will tell you when it make sense to make use of "reusable" libraries. Experience will also teach you that "reusable" libraries tend not to be.

      On the system[1] I'm typing this message on:

      $ ls /usr/lib/*.so | wc
      570
      $

      With a handful of exceptions like lib[cm], libX11, libqt, etc., it's more a general problem.

      And I re-used a lot of libraries that made things simple and quick for me. The new requests coming in involve capabilities beyond those of the frameworks.

      That's really where you made your mistake. Experience will also teach you that development cost is irrelevant in any software project that will get used. Maintenance cost (and the cost of adding additional features over time) will dominate.

      "Quick and dirty solutions are always the latter, rarely the former".

      [1] Development-wise, I'm only coding Perl at the moment and beyond XEmacs and Perl I haven't really needed to install much development stuff and so I haven't.

    14. Re:It's knowing when by wprager · · Score: 1, Funny

      You forgot:
      5. Profit

    15. Re:It's knowing when by SL+Baur · · Score: 1

      That would work for me. It's a little simplistic (good programmers can also document code, trouble shoot problems, etc.), but certainly that covers the basics.

      The key word is maintainable. Maintainability of newly written code is just about everything.

    16. Re:It's knowing when by PJ+The+Womble · · Score: 1

      It's not rewriting code or reusing code that makes you a successful programmer: it's knowing when your project manager wants you to rewrite or reuse code for "business reasons". As I have found out to my cost in the past.

    17. Re:It's knowing when by SL+Baur · · Score: 1

      That's a little too simplistic, isn't it? What good is code that works well and is maintainable if the system it runs on has become obsolete?

      If it is maintainable (which also implies well-written), then it is a straightforward task to port this to another system. I'd rather deal with rewriting a program written in maintainable HP1000 assembly language than something in a modern language that has become unmaintainable over time as hit & run programmers have made unsupervised and ill-advised modifications over the years. (Oh wait, I'm doing that right now, it's a nightmare, even though it's not particularly obfuscated Perl).

      Development time must be taken into account

      Rarely is that really an issue. If you're talking about rewriting something the size of XEmacs, then yes. There are many factors to take into account. In the case of XEmacs it's backwards compatibility to 30 years of emacs lisp. In the case of other apps, it may be compatibility with gigabytes or terabytes of database data.

    18. Re:It's knowing when by f1vlad · · Score: 2, Insightful

      Sometimes it's actually useful for one to try to reinvent the wheel, if you will; then for that person to realise that that wheel has been invented already and start using old wheel with the some knowledge gained from aforementioned attempts.

      That is the kind of path I went down. :) Depending on a person, that could actually work quite well.

      --
      o_O
    19. Re:It's knowing when by SL+Baur · · Score: 2, Insightful

      Often you spend a lot of time creating sophisticated abstractions to ease future extensions only to find that the future is so different than you expect that your elegant architecture is just code bloat.

      I don't. There's a different term for that - "Over Engineering". The OO fad has certainly contributed mightly towards encouraging over engineering.

      Avoid putting artificial limitations into code where they should not and need not exist. That will do you well in most cases.

    20. Re:It's knowing when by try_anything · · Score: 5, Insightful

      Did he really make a mistake? He already has one version out and is now finding out what the software really needs to do. That sounds pretty damn successful to me. Now he's dithering about rewriting and replacing some of the libraries, which he would have had to do anyway even if they were custom-written.

      If he had written everything from scratch:

      • Would he even be done coding?
      • Would his custom code be any more adaptable to the new requests than the existing libraries that he used?
      • Would he have ended up coding custom libraries for functionality where his needs were actually quite typical, and well-served by existing libraries?

      His original choice was correct. As far as replacing Hibernate, he's in just as good a position now as he would have been if he had written his own persistence layer. Remember, he chose Hibernate, which turned out to be unsuitable, because didn't know the requirements when he started. He would have been damn lucky if he had just happened to develop a custom persistance layer that neatly anticipated the unknown requirements. So, ripping out or rewriting the persistence layer was inevitable. If you're going to throw code away, it might as well be code that you got for free, instead of code that you sweated and toiled over.

      If you're really dead set against replacing or rewriting any libraries, the only way to improve your odds is to use the biggest, oldest, kitchen-sinkiest, most bloatiest library you can find.

    21. Re:It's knowing when by SQLGuru · · Score: 1, Flamebait

      Laziness is not a bad trait, since this will sometimes help you decide where you are best spending your energy. The bar is a good answer, but not applicable in this scenario ;)

      I like to say that there is a fine line between laziness and efficiency. The only difference is that efficient people actually get stuff done. Lazy people are just.....lazy.

      Layne

    22. Re:It's knowing when by LinuxInDallas · · Score: 1

      And number 5: Doing items 1-4 quickly and efficiently.

    23. Re:It's knowing when by GXTi · · Score: 5, Funny

      If you're really dead set against replacing or rewriting any libraries, the only way to improve your odds is to use the biggest, oldest, kitchen-sinkiest, most bloatiest library you can find.

      And people call me crazy for embedding Emacs in everything I write!

    24. Re:It's knowing when by wwwillem · · Score: 4, Insightful

      On the spot!! If the "poster" hadn't reused code from the get-go he was probably still coding. But instead of now making a choice between "hanging in" and "starting to rewrite", there is a third and IMHO better option: Throw out the framework that doesn't fit anymore and replace it with a better fitting one. Don't jump immediately into the "and now I've to write it all from scratch" excuse.

      Your original "reuse" decision was the right one, but appearently you didn't pick the right framework. Which is normal, because at the beginning of the project you didn't know exactly what the requirements would be. Based on your improved knowledge of the application, you should redo your investigation of frameworks and find one that has the right fit.

      And if you can't seem to find one that fits, you need to do some deep-deep-deep thinking. Is your situation really so unique that nothing "standard" out there will fit in, or is it the too often happening "not invented here" syndrome.

      Don't fall into the trap of "I can do it better myself". Yes, I'm sure you can :-), but you won't have the time!! Or better said, your boss won't allow you the time.

      --
      Browsers shouldn't have a back button!! It's all about going forward...
    25. Re:It's knowing when by murdocj · · Score: 1

      I can't speak to other frameworks, but from my experience with Hibernate, you hit the wall on its abilities pretty quickly. Had he written his own persistence layer, he'd be in a position to modify and grow that code. Instead, he's hit the wall, and now he's faced with a major rewrite, instead of an evolution. Database access / persistence is an area where you are WAY better off either using or writing a fairly thin layer and taking advantage of the power of the database, rather than trying to hide the database under a framework.

    26. Re:It's knowing when by Anonymous Coward · · Score: 0

      Oh yea? Well I can write perl.
      4.) Profit.

    27. Re:It's knowing when by kv9 · · Score: 5, Insightful

      The only difference is that efficient people actually get stuff done. Lazy people are just.....lazy.

      my anecdotal evidence shows that lazy people tend to write the most nice code (to make life easier for themselves - futureproofing and all that) while "efficient" people are chugging out piles of shitty unmantainable code for 8 hours a day. I guess it's the old "work smarter, not harder" thing.

    28. Re:It's knowing when by thePowerOfGrayskull · · Score: 4, Insightful

      To add to this, never ever simply "reuse" code; if you just copy and paste you'll end up with a horribly designed hack job worth of TDWT

      The fact that you seem to think that "copy and paste" is synonymous with "reuse" is a bit disturbing...

    29. Re:It's knowing when by azgard · · Score: 1

      I agree. I maintain or improve some 30+ years old mainframe applications (in COBOL, C and mainframe assembler). They are not written in any "reusable" way at all. And we still have to re-architecture them somehow, and we manage to do that with the minimal amount of change required.

      On the other hand, we have some Java and distributed people over there (and I know of others from other companies). They are trying to do things in a reusable way (OOP, patterns and whatnot).

      The funny thing is, it actually seems that Java folks are much more prone to rewrites (for example, into another framework) than we are, even though they supposedly use better methodologies. I think this is a psychological problem - they have 5 years old app, and it looks horrible, and they think, OMG, we have to rewrite it so it's more maintainable in the future. If it would be here 30 years, it would look even more horrible, and still, it would be possible to maintain it somehow. What I mean is that good maintainability is partly an illusion that depends on age of the application and maybe experience of programmer with maintenance of really old apps.

    30. Re:It's knowing when by Duckie01 · · Score: 4, Insightful

      Did he really make a mistake?

      Maybe.

      He already has one version out and is now finding out what the software really needs to do. That sounds pretty damn successful to me.

      It sounds like a mistake in the design stage to me. Did he interview the people who were going to use his software? Did he understand what they were going to expect from the software? Did he analyze the information needed by the software, and by its users? Did he define the software's scope and discuss it with its users?

      I get the impression he didn't make the mistake of coding *beyond* the requirements, which is almost always a waste of time... But did he take a well coordinated effort to get the requirements clear before he wrote the first line of code or even chose the framework?

      Now he's dithering about rewriting and replacing some of the libraries, which he would have had to do anyway even if they were custom-written.

      Of course you'll chose to use libraries over writing it by yourself. I'd like to emphasize tho that the biggest benefit is not the time you'd need to write the code... but the time you'd need to debug it!

      Libraries have usually been out in the wild for some time, been used in many different situations by different people, been looked at, debugged, improved, simplified and documented. Quite often all the functions in a library have a coherent interface, which makes for easy, "intuitive" use and a short learning curve.

      So on my left I have hard time writing pages of code and annoying debug work, and on my right I have a comfortable ride quickly producing nice looking code that just works.

      My two non-lazy braincells tell the rest of them that it's a no brainer ;)

      [...]

      Remember, he chose Hibernate, which turned out to be unsuitable, because didn't know the requirements when he started. He would have been damn lucky if he had just happened to develop a custom persistance layer that neatly anticipated the unknown requirements.

      Yeah. Very lucky indeed. To get a decent course in software engineering, with an emphasis on interviewing techniques and information analysis. You don't really *need* to just code something out of the blue and be lucky to meet the requirements. It's not necessarily a process of trial and error.

      The people you're writing software for can tell you what it's required to do. You can make a crude design and discuss it with them without even writing a single line of code. Once you have your design you start looking for an environment to implement in.

      I think that would have had a good chance of avoiding the hassle in the first place. Right now he's doing what he should have done before writing the code, and finds his hands tied to a codebase and a framework that he probably would not have used if he'd taken time and effort to get the design right!

      So to the guy asking the question... You cannot answer those questions without getting your design right... treat the code you have now as just a piece of code out there... then trust your laziness to chose the right tools to get the job done. If that's gonna be what you wrote yourself and the framework you're using now, or something else, who cares?

      [...]

    31. Re:It's knowing when by Anonymous Coward · · Score: 0

      It's not rewriting code or reusing code that makes you a great programmer. It's knowing when to rewrite code and when to reuse code that makes you a great programmer.

      Actually it's all of the above and more...a great programmer can:
      1) Evaluate the suitability of existing code for the task
      2) Use the existing code appropriately
      3) Write excellent readable, maintainable code when needed (and only when needed) to fill the gaps
      4) Communicate well with the business to understand the problem and design a solution

      Each of the above skills you're missing decreases your chances of success.

      Which in summary is exactly what the parent post stated.

      Being a great poster is not starting topics or replying to topics, it's knowing when to start topics and when to reply to topics :)

    32. Re:It's knowing when by umghhh · · Score: 1

      It is not an illusion but of course you are right about experience - it helps quite a lot. There is however level of chaos in the code that makes it completely useless as soon as any change (due to new requirements or a fault fix) is needed. hacking your way through is of course the fastest way then you might think. OC as the whole thing survived 30y then it is of high quality one might think so the hacking is limited too. The new stuff however is a different thing though.

      I happen also to work with the system that has its origins 30y ago. There are terrible things hidden there but as they were simpler than anything that we create today they are also simpler to fix. They are also mature which means they work most of the time.
      I have impression however that the new stuff if screwed up properly is way more difficult to fix than the old. The reason may be that way back then the word 'agile' was not known among software developers. I ma not sure I love or hate the cowboys that do the coding today - worse they are more work I have so I should love them I suppose.

    33. Re:It's knowing when by Anonymous Coward · · Score: 0

      It's not rewriting code or reusing code that makes you a great programmer. It's knowing when to rewrite code and when to reuse code that makes you a great programmer.

      Actually it's all of the above and more...

      No its not... the way it works is:

      1.- Write tons of code
      2.- ?
      3.- Success!

    34. Re:It's knowing when by famebait · · Score: 1

      Well, you should of course not write sophisticated extension abstractions before you need to.

      But you _should_ lots of _simple_ and low-cost abstractions that make sense, and make it easier to add that extensibility if you need it. Even the dirty shortcuts we all have to make sometimes can be done in good ways and dumb ways. At least put a dirty implementation behind a simple but clean API so you can fix it without changing the rest of the code.

      Always think in terms of interfaces: The important point of a piece of functionality is _not_ the current implementation (as long as it works) but how the rest of the system sees and needs to see it. What is the "contract" that the module and its clients agree on? You don't have to design it with every future need in mind, but it should be well-defined and clear, and require as little knowledge as possible to use right. That way so you can think more clearly about one of the parts at a time, and you can easily add what you need later. Program like you're writing a library, so when you're using one of your own modules but not working on it, you should not have to think much about how it works.

      If you need to solve equations and set the result in tex, put the solving and the rendering in different single-purpouse modules that will be easier to reuse.

      Don't write a full plugin system with auto-update infrastructure which you won't use. But you do want to isolate and localize the entry points that such a system might use, because that inevitably also expresses the structure of the problem you're trying to solve. This will make your code more efficient to work with too, even if there never is a version 2.

      --
      sudo ergo sum
    35. Re:It's knowing when by BotnetZombie · · Score: 2, Interesting

      To add to this, Hibernate is open source and it might well be possible for him to tweak it to what he needs - the transactional model is for example somewhat extendable out of the box.

    36. Re:It's knowing when by Anonymous Coward · · Score: 0

      Did he really make a mistake? He already has one version out and is now finding out what the software really needs to do. That sounds pretty damn successful to me.

      Typical agilist, having to invent arbitrary success criteria for obviously ailing projects.

      You might as well call Mao's "great leap forward" a success. Those 40 million people died so that China could find out the "real" way to run an economy (even though America got it right from the start, thanks to the up-front design enshrined in the constitution by the founding fathers).

    37. Re:It's knowing when by julesh · · Score: 3, Insightful

      The OO fad has certainly contributed mightly towards encouraging over engineering.

      I don't think I would call a form of programming that has been pretty-much the dominant form for nearly 20 years now and is showing no signs of giving way to any other form a "fad".

      I'm also not sure object oriented programming itself has contributed that much to *causing* over-engineering. It just makes over-engineering easier, so is particularly attractive to people who do over-engineer their code.

    38. Re:It's knowing when by uberdilligaff · · Score: 1

      As Fred Brooks noted in The Mythical Man-Month, you should "plan to throw one away - you will anyhow".

      --
      Against stupidity, the Gods themselves contend in vain. --Friederich Schiller
    39. Re:It's knowing when by MadMidnightBomber · · Score: 5, Interesting

      "Wall along with Randal L. Schwartz and Tom Christiansen writing in the second edition of Programming Perl, outlined the Three Virtues of a Programmer:

      1. Laziness - The quality that makes you go to great effort to reduce overall energy expenditure. It makes you write labor-saving programs that other people will find useful, and document what you wrote so you don't have to answer so many questions about it. Hence, the first great virtue of a programmer. Also hence, this book. See also impatience and hubris.

      2. Impatience - The anger you feel when the computer is being lazy. This makes you write programs that don't just react to your needs, but actually anticipate them. Or at least pretend to. Hence, the second great virtue of a programmer. See also laziness and hubris.

      3. Hubris - Excessive pride, the sort of thing Zeus zaps you for. Also the quality that makes you write (and maintain) programs that other people won't want to say bad things about. Hence, the third great virtue of a programmer. See also laziness and impatience."
      http://en.wikipedia.org/wiki/Larry_Wall

      --
      "It doesn't cost enough, and it makes too much sense."
    40. Re:It's knowing when by Anonymous Coward · · Score: 0

      "Well, I think the GP has a point"
      Yup, and I, for one, think that the point is situated on the very top of his head. The art of facile and non-productive observation is a hard art to practise - but the GP has this art down and mastered.

    41. Re:It's knowing when by Aladrin · · Score: 2, Interesting

      I'll add my own anecdotal evidence, too. I've long said that I'm a good coder because I'm lazy. I absolutely abhor doing something over and over, so I'll make sure I can reuse as much as possible when coding, and automate as much as possible when doing system stuff. When one of my fellow employees quit, I took the majority of his work and turned into Perl scripts. Literally. What used to take him hours each day now takes minutes... And because I've made it so easy, others can do it as well.

      --
      "If you make people think they're thinking, they'll love you; But if you really make them think, they'll hate you." - DM
    42. Re:It's knowing when by theaveng · · Score: 4, Insightful

      I agree. Laziness is often the same thing as "saving time". Why reinvent the wheel when somebody already did the work?

      Here's a good illustration from the 8-bit gaming era:

      - Pitfall II was created by the original programmer for the Atari 2600/VCS. Activision wanted to port this extremely successful game to other platforms, including the new Atari 5200/Supersystem and the Commodore=64. Activision assigned this task to two programmers who also happened to be good friends.
      - The C=64 programmer decided to recreate the whole thing from scratch.
      - The A5200 programmer decided to directly copy the code, and only change the pointers as needed.

      The A5200 programmer finished his task in only half the time as his friend. He then used the extra days to program an entirely new level into the game (think Pitfall III). Reusing the code allowed him to create two games, instead of just one game.

      --
      FOX NEWS.com should be BANNED from television and internet. Have the Congress take it over and give us Truespeak.
    43. Re:It's knowing when by bigman2003 · · Score: 3, Insightful

      This is an excellent example of a project with an end date. The game ships, and then you're done. No updating.

      I've been working at the same place for 8 years, not a long time, but not just a blip on a resume either.

      We are still working on the same projects from 8 years ago. Some of them were built using a framework, some were not. We ran into a lot of problems with frameworks. Honestly, if the projects had end dates, everything would have been fine, but they didn't.

      We found that as time went on, the framework may or may not be upgraded along with the software it sits on. If it doesn't get upgraded, then you may have a problem where you cannot upgrade the underlying software. Sitting on an OS that is 2 versions old because the framework uses that particular API is not fun.

      Another problem I ran into, was when the framework WAS kept up to date. As another poster said, we 'massaged' the heck out of the code. A new version comes out, and there are incompatibilities. The new framework can't just be dropped in. We need to re-do all of our work.

      The stuff we have coded ourselves is easier to maintain. On the downside, any new features need to be written by us. On the upside, that is never a problem. We had developed 18 separate projects in the first 4 years I worked at this place. Now we've been able to morph them all into 1 project. That meant taking them off of the frameworks they were on (3 different frameworks) and code everything ourselves.

      Coding it ourselves ensures that everything works together. If we had re-used a lot of code, then the systems just couldn't be integrated together nearly as easily.

      I've tried it both ways, and for my situation, writing my own makes more sense.

      --
      No reason to lie.
    44. Re:It's knowing when by Anonymous Coward · · Score: 0

      Hibernate attempts to be "invisible" to the app, so it may be harder to replace than something that actually creates more obvious seams.

      If you use the Active Record pattern (one record, one object) and limit support to one database enging, creating a *simple* object-relational bridge is trivial. It can be done in less than 100 lines of code, and is less work than setting up Hibernate.

      So, for this particular case, it is likely that it would have been less work to write from scratch. This obviously depends on the kind of problem you are facing - some problems end up with nice library APIs and no reason to write your own code from scratch, others need complex APIs and have reasons to write form scratch.

    45. Re:It's knowing when by fireboy1919 · · Score: 1

      Part of that is knowing how to use the libraries that you need.

      There is but a single construct within normal SQL that can't be represented in Hibernate - functions in subselects anywhere except the select subclause.

      You can do absolutely everything else, and there's even a workaround for that - use functions only within the select subclause, or use formulas (same thing). My guess is that you didn't actually look into how HQL works.

      Anyway, what I'm getting at is that there are libraries for a single task, and libraries to make programming itself easier. You've chosen libraries that fall into the second category. If it's not making your life easier most of the time and at *every* level of scalability, you're probably using them wrong.

      My general experience is that libraries that implement a lot of extra functionality that you don't need, but that you *have to use* in order to use them are generally more pain than they're worth. If you need to extend, you often have to implement lots of extra stuff that you're not using. Otherwise, the libraries give you a good starting place, if nothing else.

      --
      Mod me down and I will become more powerful than you can possibly imagine!
    46. Re:It's knowing when by Anonymous Coward · · Score: 0

      There is value in knowing your code. There is value in having all code in your standard style, in your standard locations, with your standard version control history available. There is value in not spending time investigating frameworks. There is value in avoiding the risk of people changing your dependencies under your feet. There is value in avoiding the complexity of a solution that solves more than what you actually need solved.

      Whether this value exceeds the value you get from a framework vary from case to case. If you really do have an excellent team with excellent practices, I believe it fairly often do. For teams I've worked on, we've about half the time ended up regretting using external frameworks - and most of our serious grief (as in hard to find and hard to fix bugs) has been with external frameworks. That said, if we'd used ONLY self-written code, what we achieved would have impossible with our team size - so there is a trade-off involved.

      I'll mention that the Excel team at Microsoft used to have the motto "Find external dependencies and eliminate them", and did this down to the point of actually maintaining their own C compiler. I understand them, though I think that might be overkill.

    47. Re:It's knowing when by Gr8Apes · · Score: 4, Interesting

      I agree with you - pretty much anytime you're looking at a long running project you're better off not using frameworks that have cut corners in areas to "make it easier for developers". Frameworks like Hibernate are especially guilty of this, since those pesky DBs are just too hard for those poor little devs to learn how to interface with using the standard library (JDBC - which, btw, still morphs but usually keeps backwards compatibility)

      I personally find hibernate to be fine for simple POC's or very simplistic apps that have a definite EOL. Anything else, don't use these persistence frameworks because they'll wind up costing you more time in maintenance than having written a specific layer for your system in the first place. I've seen several projects where the Hibernate/JDO persistence layer code ran into the tens of thousands of LOCs, because the DB no longer matched the simplistic object table layout these frameworks assume. And even when you're looking to use simple tables, linking multiple commits in a transaction winds up being more difficult than it needs to be, especially if that transaction is "handled" by Spring:

      Spring - that's another one. Spring has a special place in my heart, as I see it as the Darth Vader of frameworks corrupting otherwise workable architectures everywhere. After more than 5 years of having to deal with it, I've concluded that if I can remove Spring from any project I'm working on, I will. It will save me significant time in the future. It's a poor substitute for real AOP. It masquerades as this wonderful factory (5 lines of compile time checked code without Spring, a min of 2 lines of runtime checked code with 9 lines of xml with Spring) that can inject all sorts of nastiness into your system and requires runtime debugging to figure out why the heck you don't have the object you thought you had, from the service you wound up actually not calling, 6 layers deep.

      Now, with all that said, sometimes you have to work with these systems, because there's no business case for removing them. It appears the OP has finally gotten to the point where there is a business case for revisiting his persistence layer, and if he's designed the access to Hibernate correctly on the edge of his application, it won't be too bad to remove Hibernate and install his own layer. If he's used the Hibernate calls throughout his code, he may wish to first migrate everything behind an internal API, and then start migrating code.

      --
      The cesspool just got a check and balance.
    48. Re:It's knowing when by DuckDodgers · · Score: 4, Insightful

      I think the point is important to clarify for people who legitimately don't know the difference. Not everyone who starts reading Slashdot and thedailywtf already understands good software engineering practices.

      I've even worked with senior developers who think "cut and paste" is code reuse. Clearly they were not spending enough time on sites like this one.

    49. Re:It's knowing when by DuckDodgers · · Score: 1

      Your position on Spring is interesting. I work with Java web stuff, and I was wondering which technology to pick up in my spare time to better prepare me for a future job.

      From what you write, it sounds like Spring may be worth knowing because it's commonly used but definitely not worth adding to a new project in most cases.

      As far as Hibernate... the learning curve on Hibernate is a bitch. But if you hunt around enough, you can configure it to work with almost any kind of weird table relationship. What would you use instead? Raw JDBC?

    50. Re:It's knowing when by DuckDodgers · · Score: 1

      What walls? Could you give examples or a link?

    51. Re:It's knowing when by jellomizer · · Score: 1

      That and Bad programmers will often stick to a single methodology like a crutch. Oh I can't do X because I don't have libraries to do so, or this language doesn't support it (without writing new code), Then there are others who always need to rewrite code at great expense as his ego makes him think that his code is better then anyone else's is. And normally makes it worse.
      The trick is to think of it in a business perspective (Yes Yes this is EVIL on Slashdot) but it comes down to this. Will reusing code still be faster then making it from scratch debugging your code and then have the people use it as Alpha and Beta code and have potential problems. Or is better to rewrite the code as it will be much more easily maintainable and upward compatible and offer a better value over time. When considering the scope you need to keep in mind the expected life span of the product. Some Apps will only last 2-6 years others will be around for decades. Sometimes the requirements change so much over time that any methodology will be silly and you may just be better off dumping any attempt to make it look like stellar CS A+ Grade code and stick with down and dirty documented as best you can ugly code. As any attempts to fix it will end up just as ugly when you are done due to all the change requests.

      --
      If something is so important that you feel the need to post it on the internet... It probably isn't that important.
    52. Re:It's knowing when by johnlcallaway · · Score: 0, Offtopic

      There has only been on program ever written ... HelloWorld. All other programs are just modifications of that program and it's ancestors.

      --
      I rarely read replies, it's my opinion and if you thought about your opinion a little more, I'm OK with that.
    53. Re:It's knowing when by TheSeventh · · Score: 1

      he probably would not have used if he'd taken time and effort to get the design right!

      . . . yeah, because people never change their minds after you interview them and later they discover that what would be "really great" is if the project could also do such and such . . .

      Of course, you could always tell your manager that if they wanted that added functionality they just mentioned, that they should have requested it 6 months ago when you asked them. Because you know, that usually works, and goes over quite well to boot.

      I'm sure your manager will know better next time. Will know better than to ask you to work on their projects.

      --
      Just because you're paranoid, it doesn't mean that they're not out to get you.
    54. Re:It's knowing when by DriveMelter · · Score: 1

      I'm not a big fan of the over-engineered phrase. It implies something is perhaps more robust and fault tolerant than it needs to be but it is used when something is overly complex rather than over-engineered. Our office phrase for something that's overly complex is "he's re-factored the f*** out of it"

    55. Re:It's knowing when by mysticgoat · · Score: 1

      Say No when appropriate

      Exactly.

      The problem here is not a coding problem. It is a political problem. That was named correctly in TFSummary: "feature creep". No changes in coding practice are going to fix this. This has to do with the other part of the programmer/analyst job: the analytical part. Which includes a political component. Which maybe in this case needs more attention than it has been getting.

      Author is functioning as a programmer/analyst and not just a code monkey. He is the one who is making the architectural decisions about whether to borrow from an existing library or build from scratch, etc. So he is also the one responsible for analyzing each proposed change and deciding whether it belongs to the current project, or should go on the wishlist for the next version. The next version would be a new project that does not yet even have specification.

      The political component is mostly communicating to others that he has to make these decisions to get anything done, and devising a road map that shows the non-programmers in his world when various proposals can be addressed. "Planning Version 2.0" should be prominent on that road map.

    56. Re:It's knowing when by Tijaska · · Score: 1

      6) Leap tall buildings with a single bound
      7) Fly faster than a speeding bullet

      It's just pity that there are so few great programmers around. We need to learn to get by with what we have, slow-stream plodders like me.

    57. Re:It's knowing when by cylcyl · · Score: 1

      Erm... Does C-64 assembler work anything like A2600? As A5200 was the next gen of A2600, it's quite likely the assemblers work similarly, even if it's not directly compatible...

    58. Re:It's knowing when by murdocj · · Score: 1

      It's been a while so I'm going to be a bit vague, but as I recall we had trouble with relationships between objects.

    59. Re:It's knowing when by godefroi · · Score: 1

      I've long said that better programmers write simpler code. Poor programmers write complex code.

      --
      Karma: Poor (Mostly affected by lame karma-joke sigs)
    60. Re:It's knowing when by orclevegam · · Score: 2, Insightful

      Now that Hibernate and EJB3.0 have effectively merged, you might as well learn Hibernate because one way or another you're going to be using the same basic system no matter what you choose (raw JDBC possibly excepted, but in that case you're responsible to maintaining all the JDBC calls and making sure they keep pace with your SQL updates). Hibernate really is incredibly flexible, and I find it hard to believe you could possibly have anything you need to do that can be done in JDBC but not Hibernate (in particular since you can use JDBC inside of Hibernate, although it does remove a lot of the nicer things Hibernate does).

      As for Spring, you might be right in that there are some frameworks that a more true to AOP, and that if you're not careful Spring can bite you, but the basic premise of Spring is definitely a good one. In particular, learning and using the annotation based configuration options of both Spring and Hibernate will go a long way towards improving the usability of both frameworks. Coming from a project in which we ripped out a lot of really nasty singleton code (and byzantine object relationships and factory methods necessary to make it work) and replaced it with a very simple dependency injected model built on top of Spring, it really is a nice framework that can lead to some very clean code. The real beauty of Spring though isn't just the dependency injection (which is nice), but in the very clean straightforward components it ships with (like Spring MVC web framework which is one of the better ones I've seen). In addition, managing transactions through Spring can greatly simplify your project, but you've got to design your persistence layer with clear entry and exit points for each transaction to allow them to be annotated with the start and commit transactions, otherwise you're going to struggle with managing the transactions.

      --
      Curiosity was framed, Ignorance killed the cat.
    61. Re:It's knowing when by mypalmike · · Score: 1

      > Does C-64 assembler work anything like A2600?

      Yes. They all were based on MOS 6502-series chips.

      --
      There are 0x40000000 types of people: those who understand 32-bit IEEE 754 floating point, and those who don't.
    62. Re:It's knowing when by orclevegam · · Score: 1

      I'll mention that the Excel team at Microsoft used to have the motto "Find external dependencies and eliminate them", and did this down to the point of actually maintaining their own C compiler. I understand them, though I think that might be overkill.

      Pfh! Real Men do it in assembly (and Masochistic Real Men do it in machine code).

      real_men.com (no line breaks)

      X5=!P%=AP[$\PZX5F(P^)7CC)7}!Real men do it in machine code! $H+H*

      --
      Curiosity was framed, Ignorance killed the cat.
    63. Re:It's knowing when by Gr8Apes · · Score: 1

      With Spring, it really depends upon what you're working with, not that it excuses the existence of Spring, but that's a different story.

      Core: Dependency Injection (the initial biggie and raison d'etre) - if you're only using this for testing, why would you inject test code in your production code? (yes, pun intended). Otherwise, see above statement about 5 lines of code in most cases for a hard compiled factory, or possibly as few as 10 for a reflection based factory. Either way, Spring's use in this category is usually abused to allow for things like circular dependencies - really bad idea.

      DAO: Haven't really used this directly, although it's been inflicted on me via a third party app. Spring transactions get rather abrupt comments from Hibernate folks in hibernate forums. If you want a nice migraine, try debugging why a particular transaction is broken when you change 1 minor operation, like, say, add a field to an object.

      ORM: all third party stuff, why not use them directly? Unless you just enjoy writing more XML.

      AOP: A poor man's dynamic proxy approach to AOP. This can have some interesting side effects if you actually expect a specific object.

      JEE: heard the EJB part was good, but I avoid EJBs like the plague.

      WEB: Spring MVC - who uses this? Seriously. I've never seen it in an enterprise environment. It's sort of like Struts 2, it might be nice, but it's MIA.

      But you should definitely learn about these technologies, because knowing them will allow you to make better decisions.

      --
      The cesspool just got a check and balance.
    64. Re:It's knowing when by orclevegam · · Score: 2, Insightful

      I've long said that better programmers write simpler code. Poor programmers write complex code.

      Better programmers write Elegant code, which is just as complex as it needs to be to get the job done, and no more.

      --
      Curiosity was framed, Ignorance killed the cat.
    65. Re:It's knowing when by Duckie01 · · Score: 1

      he probably would not have used if he'd taken time and effort to get the design right!

      . . . yeah, because people never change their minds after you interview them and later they discover that what would be "really great" is if the project could also do such and such . . .

      They do, and you, as software engineer, you *know* they will.

      Of course, you could always tell your manager that if they wanted that added functionality they just mentioned, that they should have requested it 6 months ago when you asked them. Because you know, that usually works, and goes over quite well to boot.

      Yeah you could. But I believe the results would be less desirable than the suggestion I offered. Did you even read the entire comment?

      I'm sure your manager will know better next time. Will know better than to ask you to work on their projects.

      Perhaps he might, if he'd go along with the words you try to put into my mouth.

      Other than that he might be happy with someone who doesn't sit around waiting for a customer to "change his mind" about the functionality of a program, but actively participates in this "mind changing" during the design.

      Or he might be happier hiring a "programmer" who knows nothing about design.

      Perhaps he might even hire a troll. Who knows.

    66. Re:It's knowing when by jgrahn · · Score: 1

      When one of my fellow employees quit, I took the majority of his work and turned into Perl scripts. Literally. What used to take him hours each day now takes minutes...

      Let's hope none of his former colleagues tells him about it :-)

    67. Re:It's knowing when by hiroller · · Score: 1

      Actually, I wouldn't even create a temporary compatibility layer since everything that is temporary in our code tends to stay in the base entirely too long. We had a similar issue when our project requirements could not be sustained by LLBLGen, the original accessor to our data persistent layer. As we phased out the LLBLGen, we created a service layer and abstract factory class which represented our DAL and was primarily developed with dependency injection and testing in mind. It has actually worked out really well since we are having to modify our data access layer again to compensate for data retrieval on the bus. It is a little extra work but allows for more flexibility in the future.

    68. Re:It's knowing when by MikeFM · · Score: 1

      And knowing when to wrap code. Write a lightweight layer between third-party code and your own so if you need to change it you can do so without rewriting your entire program. ie Don't include MySQL specific code throughout your program - have a db lib that provides generic functions that you can tie to MySQL but easily change if you move to Oracle or something.

      --
      At what price learning? At what cost wisdom? The price is a man's peace of mind, and the cost is his life.
    69. Re:It's knowing when by beatle11 · · Score: 0

      You should always re-use code when you can. At first you thought you could re-use the code. Then you get Scope Creep. Another example showing why Scope Creep is bad. Set your requirements at the begining.

    70. Re:It's knowing when by try_anything · · Score: 1

      Yeah. Very lucky indeed. To get a decent course in software engineering, with an emphasis on interviewing techniques and information analysis. You don't really *need* to just code something out of the blue and be lucky to meet the requirements. It's not necessarily a process of trial and error.

      The only requirements you can get from users are the ones that they consciously understand and can verbalize effectively. There are painstaking processes you can go through with the users to develop that understanding together. One of the best, in my experience, is showing them working software, or a good mock-up.

      Don't think of an unusable early version as a failure. Think of it as a requirements gathering tool, and compare its cost to the cost of doing comprehensive up-front requirements gathering without it.

    71. Re:It's knowing when by istartedi · · Score: 1

      I get the impression he didn't make the mistake of coding *beyond* the requirements, which is almost always a waste of time

      Apparently, you've never worked with a manager who always says "It only needs to do a handful of operations", "no, it doesn't need to be configurable" and "we only want one view of the data". I soon learned that what he really meant was "it must scale into the thousands", "technicians might want to tweak that" and "the more views we have on the data, the better".

      --
      For all intensive purposes, "whom" is no longer a word. That begs the question, "who cares"?
    72. Re:It's knowing when by Crias · · Score: 1

      Sorry Duckie, but you're still missing the point.

      I'm working on a project that's been going probably 10+ years. No, I wasn't one of the originals - none of them are even around. So just pretend for a moment that all the technology we have today was available 10 years ago. You're pretty pro, think you can get _all_ of the requirements for the next 10 years and beyond out of your client on the first try before you write a single line of code? Good luck.

      Customers don't know what they want. Period. You can ask them, interview them, and you'll get a lot of very telling answers. You'll build what they said they wanted... and it's not what they wanted! Why not? Because it was what they wanted 6 months ago when you started.

      Worse than that, customers have a nasty habit of not knowing what they want until its delivered. We did a photoshop mockup of a UI for a feature we were adding, and got it approved by our customer, before proceeding on a recent feature-addition. He still liked it the day we tried to deliver... until he used it. Then we spent another two weeks changing the UI and some of the underlying functionality linked to it.

      The fact of the matter is that the requirements and scope change. You can't prevent it. Yes, you should spend some time determining requirements, try to minimize the harmful effects of change, but you cannot _cannot_ prevent it.

      Perhaps he might even hire a troll. Who knows.

      Perhaps he might even hire an Agile programmer instead of a Waterfall one. Who knows.

    73. Re:It's knowing when by artsrc · · Score: 1

      Copy and paste may be better than typing the same thing in by hand.

      Copy, paste and modify has lower effort and may have lower risk than creating the needed abstraction, refactoring the source to use it, and then adding your new usage.

      Effort and risk are needed to keep a code base maintainable. Because engineering requires trade-offs is also requires discipline.

    74. Re:It's knowing when by Pieroxy · · Score: 1

      To get back on track, there are numerous projects that change over time and are not subject to design flaws.

      In my experience, I have mostly worked with such projects: Web Sites. These pieces of software are designed, then they live for years and years and keep evolving. There is nothing wrong with that.

      I also found out that no matter what framework you will use, you will end up needing more or different things from it. What may have been a good idea at some point will be a bad one after enough iterations of the project.

      That goes for all frameworks regardless. It is of course not true for straight libraries (AXIS comes to mind) because they are at an endpoint of your software stack and don't require major changes if removed.

    75. Re:It's knowing when by two+basket+skinner · · Score: 1

      To add to the point above about "knowing when," Jeff Atwood believes that you should write the parts of the system critical to your business and reuse code for the rest. For example, if you are a bank, write your own banking software but reuse code for web front-ends.

    76. Re:It's knowing when by Duckie01 · · Score: 1

      Sorry Duckie, but you're still missing the point.

      It remains to be seen who's missing what point.

      I'm working on a project that's been going probably 10+ years.

      Which is entirely different from coding something from the ground up and then finding out it doesnt meet the requirements up to a point you might need to throw out your codebase and the framework it's built on, right?

      No, I wasn't one of the originals - none of them are even around. So just pretend for a moment that all the technology we have today was available 10 years ago. You're pretty pro, think you can get _all_ of the requirements for the next 10 years and beyond out of your client on the first try before you write a single line of code? Good luck.

      No, I don't think you can, and I'd like you to point out where I wrote that, before telling me I'm missing any point.

      Customers don't know what they want. Period. You can ask them, interview them, and you'll get a lot of very telling answers. You'll build what they said they wanted... and it's not what they wanted! Why not? Because it was what they wanted 6 months ago when you started.

      Worse than that, customers have a nasty habit of not knowing what they want until its delivered. We did a photoshop mockup of a UI for a feature we were adding, and got it approved by our customer, before proceeding on a recent feature-addition. He still liked it the day we tried to deliver... until he used it. Then we spent another two weeks changing the UI and some of the underlying functionality linked to it.

      The fact of the matter is that the requirements and scope change. You can't prevent it. Yes, you should spend some time determining requirements, try to minimize the harmful effects of change, but you cannot _cannot_ prevent it.

      No, but you can do the work good enough to not need throw away your codebase.

    77. Re:It's knowing when by Anonymous Coward · · Score: 0

      And since you can't gues the future, ALWAYS write it yourself, until you come up with the correct abstraction.

      If that were not the case, new frameworks would not appear. Someone's frustrations with the old framework creates the new framework. This process has been repeating again and again for the last 60 years.

      No framework is perfect. That is why you need to learn how to write a framework before you use one, not the other way around. People who only know how to use frameworks are mere script kiddies.

    78. Re:It's knowing when by Duckie01 · · Score: 1

      The only requirements you can get from users are the ones that they consciously understand and can verbalize effectively. There are painstaking processes you can go through with the users to develop that understanding together. One of the best, in my experience, is showing them working software, or a good mock-up.

      Yeah I've even made pencil and paper sketches on the fly to get the basic outline for the UI straight, while showing half a "program" that did contain the data structures but basically didn't do much of anything yet 'cept for showing three main UI pages. I did *not* mean you need to design all of the program, create it and present a finished program to the users... that'll never work.

      Also, perhaps I didn't make that clear enough in my original comment, it's not just requirements I want to find out during these interviews. I'm mostly interested in data. What data is used, and where? Once I have my data I can create the data structures I need, from there on there's just no way we're going to have to throw away the codebase because of some UI stuff we need to change.

      Don't think of an unusable early version as a failure. Think of it as a requirements gathering tool, and compare its cost to the cost of doing comprehensive up-front requirements gathering without it.

      I do like to think of an early version as something that we can grow. If I made something that isn't viable, I'd like to find out as soon as possible, and not when I'm knee deep into the project. Getting the users involved like you say does help greatly there, also just to make it grow into the right direction. Throwing out a codebase is not a disaster and not the end of anybody's life.

      However, that doesn't just mean the interviewing and data analysis have become worthless, and it's not an excuse to not do it. Poor analysis is a sure way to produce worthless code. As long as I get my data structures right we can rewrite half our code without a problem. If I get my data structures wrong, we'll find ourselves throwing out much (if not all) of the code after much frustration. Yes we did learn in the mean time but I'll still hold that it's a terrible waste of time and effort.

    79. Re:It's knowing when by Silfax · · Score: 1

      > Yes. They all were based on MOS 6502-series chips.

      But the sound, video, & i/O were handled differently on the 2 platforms. Tje programmer assigned to the C64 version was probably better off rewriting. About the only thing he would have been able to keep was game logic, not platform specific stuff.

    80. Re:It's knowing when by DuckDodgers · · Score: 1

      I don't know your particular situation. For us, we have all sorts of bizarre object relationships. But if we did enough hunting through the Hibernate documentation, we found some way to support them. It wasn't always optimal or as object-oriented as we would like on the Java side, but it worked and performance was acceptable.

    81. Re:It's knowing when by Tablizer · · Score: 1

      And people call me crazy for embedding Emacs in everything I write!

      This is recursive since Emacs already embeds everything.
           

    82. Re:It's knowing when by lamapper · · Score: 1

      ... I absolutely abhor doing something over and over, ... When one of my fellow employees quit, I took the majority of his work and turned into Perl scripts. Literally. What used to take him hours each day now takes minutes... And because I've made it so easy, others can do it as well.

      Not only over and over, I don't even want to do it twice if I can avoid it. Though I will admit any time I rewrite code it is better the second time than the first.

      My first programming job I replaced a guy who got fired because he could not get his own custom code to work. He was being cute with over 400 lines of logical ands and ors it was pathetic.

      Being too new to know any better I first tried to make sense out of his code but simply could not it was just badly written.

      I finally pulled myself away from his junk and thought about the problem. Controlling two sets of 8 switches to turn various things on and off at appropriate times based on sensors...no problem.

      Once I determined the distinct set of codes to do everything I needed it to do, I proceeded to do them at appropriate places based on the data in the sensors.

      Piece of cake, removed over 400 lines, replaced with a logical 30 - 50 lines of code and low and behold the entire software program worked like a champ.

      I learned early on about keeping it simple. Works every time.

      Sign me an average programmer and okay with that.

      --
      Is your Internet Throttled? Install DD-Wrt, OpenWRT or Tomato to learn the truth! Google: 1Gbps/1Gbps: 5 Communities
    83. Re:It's knowing when by lamapper · · Score: 1

      It's not rewriting code or reusing code that makes you a successful programmer: it's knowing when your project manager wants you to rewrite or reuse code for "business reasons". As I have found out to my cost in the past.

      You are assuming that your project direction has not changed for you due to some external influence beyond your scope and/or control.

      Often no matter how well designed, no matter how well coded, no matter how well managed, things happen, external influences that force changes to the end software product. This type of thing simply can NOT be planned for, especially if the market says No to your product due to missing critical features.

      Not much better if you determine that features not planned until multiple releases away are suddenly determined to be more critical now than previously determined by sales, marketing and business units. Especially if you do not have the budget for additional resources.

      That can happen even with good communication with your customers, the market and knowledge of the competition.

      One external influence that I really loath is when you are dependent on a discontinued proprietary commercial library or a framework (that you did not select and that you do not have access to the source code for), but its critical to the success of your project. Often the company is unable to buy it so time to find something else or start coding. Even better if the company that discontinued the framework was the only one that would do the job for you.

      Having access and ability to change the source has saved my bacon on more than one occasion. And no matter how well supported a framework or library is today, it might not be tomorrow.

      Sign me as not a big fan of third party development tools that you cannot live without.

      --
      Is your Internet Throttled? Install DD-Wrt, OpenWRT or Tomato to learn the truth! Google: 1Gbps/1Gbps: 5 Communities
    84. Re:It's knowing when by Aladrin · · Score: 1

      I'm a little slower about it. The second time I have to write code, I take a serious look at it and decide whether I will ever use it again. If I get to a third time, I refactor.

      There are exceptions to this... Notably, code that's very hard to refactor because each version needs some edge case. (Actually, thinking about that, I can see ways to refactor some of that code now... I sense work in my future.)

      --
      "If you make people think they're thinking, they'll love you; But if you really make them think, they'll hate you." - DM
    85. Re:It's knowing when by mypalmike · · Score: 1

      The Atari 2600 and 5200 platforms were as different as the 2600 was from the C64.

      --
      There are 0x40000000 types of people: those who understand 32-bit IEEE 754 floating point, and those who don't.
    86. Re:It's knowing when by Gr8Apes · · Score: 1

      Spring will bite you. It makes it entirely too easy to create bad architecture, and is entirely unnecessary.

      I'm sure you can create a "usable" project with Spring, but I doubt it will ever be simpler. Hibernate can be simpler, until your data model exceeds the basic constructs Hibernate supports.

      And lastly, yes, byzantine code is possible without Spring, Spring just makes it easier by spiking the koolaid. Dependency Injection is just a fancy way of saying "Factory Pattern", and factories are after all so notoriously difficult to write. Even Factories that build on reflection are easy which is actually the only time I might concede Spring might be a fit except for the huge dislike of Spring in my project and the fact that writing the code will only take me 1-2 minutes, whereas Spring will take me much longer, as I'll have to find the right XML file and remember the XML configuration and type in 3 times as much garbage for the same ends.

      --
      The cesspool just got a check and balance.
    87. Re:It's knowing when by orclevegam · · Score: 1
      Have you looked at Spring lately? With the annotation support that's been added recently you can eliminate just about all the XML out of Spring. You still need a single XML file that specifies the package or packages to search for annotated classes (an inherent problem with the way class loading is handled), but aside from that everything else can be configured via annotations. Injecting a service into a controller is as simple as annotating the service class with

      @Service("SomeService")
      public class SomeService {

      and then on the controller having

      @Autowired
      private SomeService theService;

      Spring takes care of everything else, including dealing with circular dependencies. Likewise Hibernate can handle any association you care to toss at it, and can be entirely configured with annotations (once again baring a single XML entry to list packages/classes to scan for annotations).

      --
      Curiosity was framed, Ignorance killed the cat.
    88. Re:It's knowing when by Gr8Apes · · Score: 1

      Great - so config has moved into annotations. What's so great about that other than you no longer have to write XML? Now, if you want to change a config, you'll have to make a code change. Yep, that's much better.

      This still doesn't remove the fact that you shouldn't need Spring within your codebase. You should only be using it at the application edges to begin with, which is where most go wrong with Spring.

      And Spring enables circular dependencies. It doesn't deal with them.

      Spring is a solution in search of a problem. It's "bettering" itself from all the criticism leveled at it, but it really doesn't solve any real world problems that aren't more simply solved via straight code.

      Now we get to Hibernate. Hibernate is fine if used as directed. The problem arises when that direction clashes with your requirements, and you wind up starting to write code to deal with specific mutations to that direction. 25K LOCs later, you have a mess that could have been easily avoided by avoiding Hibernate. Yes, I'm looking at my third project with more than 25K LOCs dealing with specific issues related to Hibernate, and this last one has Spring injected transactions to boot - oh joy! BTW, did you realize that you can side step Spring insecurity easily? Or that Hibernate sessions can be hijacked? There's all sorts of fun you can have is you put your mind to it. My point here is that these frameworks are a hindrance rather than a help when it comes to larger, more complicated projects. And what if you want to access a DB "controlled" via Spring/Hibernate? That's a fun one, especially if you'd like to extend it, or cross reference data from several objects.

      Maybe I'm just grumbly, but Hibernate and Spring both sound a lot like the koolaid passed around for EJB 1.0, 2.0, 3.0, JDO, Hibernate 1-2, .NET, JHTML, JSP, ASP, etc etc etc. Some of those had good features, but many were problematic in practice, especially for larger projects.

      --
      The cesspool just got a check and balance.
  2. prototype quickly, optimize later by evw · · Score: 4, Insightful

    If you'd tried to write it all yourself from scratch from the beginning you'd still be coding and you wouldn't have gotten the feedback about what needs to change as quickly. Prototype quickly then optimize later.

    1. Re:prototype quickly, optimize later by somersault · · Score: 2, Insightful

      And if the library you're using has an obscure bug then you could also end up wasting days of work either having to track down a bug or write your own library.. sometimes it will be fine, but sometimes you might not be saving yourself any time at all, depending on whether the library is open source, how many other people have used it and bugfixed it etc.

      --
      which is totally what she said
    2. Re:prototype quickly, optimize later by setagllib · · Score: 2, Informative

      That's fair to say, but you can be pretty confident Hibernate is a solid product. Same for Spring. They're many years old, with widespread use in open source and commercial projects. And very encouraging is how they both use unit testing from the ground up, so you can be very confident any given release is exceptionally robust.

      I wish I could say the same for the JVM they run on. There were a number of bugs in several official, supported Sun JVM releases which mis-optimised code on amd64. They seem to be fixed, but you'd think they'd test for stuff like that, since even popular projects like Eclipse were crippled by the bugs.

      --
      Sam ty sig.
    3. Re:prototype quickly, optimize later by Bad+Mamba+Jamba · · Score: 5, Insightful

      Except every time I've ever done a prototype it is invariably shipped as product minutes later.

      Naturally disaster follows.

      What you say: "I have a working prototype."

      What management hears: blah blah WORKING blah.

      Moral: Never say you have anything "working" until you're really done.

    4. Re:prototype quickly, optimize later by Progoth · · Score: 1

      And if the library you're using has an obscure bug then you could also end up wasting days of work either having to track down a bug or write your own library.. sometimes it will be fine, but sometimes you might not be saving yourself any time at all, depending on whether the library is open source, how many other people have used it and bugfixed it etc.

      having worked in professional software for quite a few years now...using open source libraries and systems as a base...

      you're better off working from the system that "somebody else" supports than writing your own

      you can write amazing and bug-free software yourself...but somewhere along the way you're going to run across a bug in the vm or OS or hardware or protocol specification that you're running on that you're going to have to work around.

      it's much easier...in a professional sense...to hit a bug in an OSS project than in some library or system or hardware from some closed-source shop that you're going to have to fight through bureaucracies to get fixed.

      exceptions exist, of course...but it's much better to say to your manager "hey we can work around this bug by spending xxx hours or we can invest in fixing the OSS project in xxx/2 hours" than saying "hey we can work around this bug by spending xxx hours or we can push this back to XYZCorp and spend xxx^2 hours getting it fixed"

      that's my experience, anyway, and you may be in a different software industry that has different outcomes than mine

      oh, and yes, always prototype and get something working....and then optimize before they realize you're even finished with the prototype. it's part of being good at what you do. if you're stupid or a bad programmer or engineer then don't try to follow this advice.

    5. Re:prototype quickly, optimize later by SL+Baur · · Score: 1

      Except every time I've ever done a prototype it is invariably shipped as product minutes later.

      You're going about it wrong.

      Develop the prototype as a proof of concept (use those words if "prototype" sends your people into a frenzy) and show them the UI with nothing attached underneath first.

      Otherwise, I most agree with the Subject line.

    6. Re:prototype quickly, optimize later by zgornz · · Score: 1

      In the book "The Art of Embedded Systems Programming" the author recommends writing prototype code in a different language, something like VB. Partially because it's just meant to be quick code anyway, and partially because then there is NO temptation to ship it.

      Interesting idea at least.

    7. Re:prototype quickly, optimize later by gnud · · Score: 2, Funny

      The simple solution to this problem is using GPL code in your prototype. Then management won't let you ship until you've replaced it with something else =)

    8. Re:prototype quickly, optimize later by iangoldby · · Score: 1

      ... writing prototype code in ... VB ... because then there is NO temptation to ship it

      Can anyone else see this idea going very terribly wrong indeed?

    9. Re:prototype quickly, optimize later by somersault · · Score: 1

      I don't think I'm particularly stupid or bad as a programmer - a bit rough around the edges perhaps because I didn't make the best use I could have of my time at University so I probably have some bad habits from being largely self taught.

      As far as prototyping, what do you mean exactly? How does prototyping differ from just coding something up quickly? Does it imply less testing or less design time or what?

      In my experience when I dived straight into writing a fairly complex algorithm without thinking fully through the design and how it works first, it turned out being a mess. I once spent a couple of days writing an algorithm for finding random paths through a graph (for some game AI I was doing) that ended up being crazy complicated, and had a seemingly random bug that I spent hours trying to track down. I then went to sleep, woke up the next morning and was able to write a much better (more concise and easy to follow) version with no bugs in an hour or two since I had a better idea of what was involved in the problem. So I've learned from that that more time spent designing before coding really helps. I can fire through the coding very quickly once I have a clear idea of the design.

      --
      which is totally what she said
    10. Re:prototype quickly, optimize later by pbhj · · Score: 1

      What you say: "I have a working prototype."

      What management hears: blah blah WORKING blah.

      What management thinks "how come he made it work so quickly when the _product_ normally takes longer and has lots of bugs; cut allowed development time".

      Seriously though if the prototype works then it's a product. Oh you mean it's got major bugs? Then it doesn't "work" (at least not properly). Or you mean it won't scale? Then can you ship it now and patch the parts that need to scale (management will probably want to wait until it actually breaks to commit resources)?

    11. Re:prototype quickly, optimize later by Anonymous Coward · · Score: 0

      How does prototyping differ from just coding something up quickly? Does it imply less testing or less design time or what?

      Less design, and almost no testing, however lack of almost any real functionality is the critical part in prototypes so that they don't end up being used.
      Prototype is a lure for catching changing requirements that will be presented by the management and customers as soon as they see your program working and realize that it is what they asked but not what they wanted. At this point changing frameworks is still possible.

    12. Re:prototype quickly, optimize later by dkf · · Score: 1

      Develop the prototype as a proof of concept (use those words if "prototype" sends your people into a frenzy) and show them the UI with nothing attached underneath first.

      If you polish the mock-up (another useful phrase) too hard, people will lose sight of the fact that there's only smoke and mirrors behind it. Even people who should know better (other programmers!) fall into this trap. So make sure that the mock-up is producing actual nonsense results and is also doing annoying stuff like popping up dialogs ("data wasn't actually saved because this part isn't written yet: OK") so that nobody thinks it is in a shippable state. It also helps if you can precede the demo with a presentation with a Gantt chart showing that this is just a small part of the overall project; while Gantt charts are dangerous, failing to manage expectations is far worse.

      (Also don't forget to write unit tests so that you can shorten the cycle time to dealing with issues and keeping them dealt with. No point in sending stuff with obvious faults to QA; let them work on the integration and acceptance testing...)

      --
      "Little does he know, but there is no 'I' in 'Idiot'!"
    13. Re:prototype quickly, optimize later by blake182 · · Score: 1

      Except every time I've ever done a prototype it is invariably shipped as product minutes later.

      All code is final code.

    14. Re:prototype quickly, optimize later by somersault · · Score: 1

      Ah, well that makes some sense, thanks. Having been on the receiving end of feature creep or outright "that's not what we agreed on" after hours of going through design ideas with management or end users, I can see the sense in setting up demo versions before fleshing everything out to make sure it's what people want.

      --
      which is totally what she said
    15. Re:prototype quickly, optimize later by Anonymous Coward · · Score: 0

      There's the phrase I've been looking for ...

      "manage expectations"

      Even on internal projects, we have provided written documents (yes, even if it means using Word) laying out what the current project|development cycle|release|version entails and how long we anticipate it will take and the assumptions that come with that. So ... when customers come back with creep, that document gets modified/versioned and they can decide if that's what they want to do. We stand our ground on some issues but allow small creep at times to help maintain a good relationship.

      As far as the original question:
      Do the research to see which is more likely to work, estimate it and tell them what that will cost (T&M). Your bigger issue/concern would be to not manage expectations at this point. Point out the previous assumptions and the impact they have now against the impending creep. If you don't have something written (not just email exchanges) ... get it written down and agreed on now.

    16. Re:prototype quickly, optimize later by Hognoxious · · Score: 1

      And if you don't polish the mock-up, they reject the system because it looks so ugly. And how can they work with a system that doesn't save the data, are you mad? Look here in the spec, it clearly says that the data has to be saved! My people can't rekey the customer master every day. I'm going to the CIO to get you fired, you idiot!!!!

      Oh, it's only a prototype, and it won't look & work like that in the end? Good luck telling the users and the PHBs - 50% of them won't undertand. 99% of them won't even listen. They're like children.

      --
      Confucius say, "Find worm in apple - bad. Find half a worm - worse."
    17. Re:prototype quickly, optimize later by Anonymous Coward · · Score: 0

      yeah but value is perceived by the user, not the developer. these days "the best is the enemy of the good", and getting something out is better than never releasing cos it aint perfect. missed out a feature in this release? never mind, there will be another one along in a minute.

      i am not saying quality has to suffer : but notions of completeness aren't the same to coder and client

    18. Re:prototype quickly, optimize later by mcrbids · · Score: 1

      Really: What is the difference between a "prototype" and "working code"? Do you actually write a prototype and then rewrite it later after you've proven the concept?

      The fact is that in most cases, the prototype and the release are both the same code base, except that one has had more testing and development than the other, as evidenced by your own statement:

      "... every time I've ever done a prototype it is invariably shipped as a product minutes later."

      This is not a bad thing! But it does require you, as a developer, to take this into consideration and develop your prototypes with a useful API and infrastructural support/optimization so that when it becomes "production code" minutes after you are "done" with your prototype, it can hold up. Let me repeat myself...

      The prototype and the release are both the same code base, except that one has had more testing and development than the other.

      --
      I have no problem with your religion until you decide it's reason to deprive others of the truth.
  3. code from scratch by lixlpixel · · Score: 1, Interesting

    code from scratch - and reuse your own code - that way you know exactly what it can do and where you have to start from scratch

    1. Re:code from scratch by Anonymous Coward · · Score: 0

      That's not always applicable. If the code is not in your area of expertise, especially if that area is security, and the code works, you are better off reusing code. But in general I am with you.

    2. Re:code from scratch by Anonymous Coward · · Score: 0

      Always code from scratch. The time saved from complete understanding of your own code is hard to describe.

    3. Re:code from scratch by Satis · · Score: 1

      I agree, code everything yourself. There's nothing wrong with coding your own frameworks and reusing those... even if something needs to be changed you know exactly how and where to do it.

      I don't mind using code for simple things (especially javascript snippets to do things that are a pain in the butt to make cross-browser). But any time I've used other peoples' code for something marginally large it's bit me in the ass.

      --
      Satis clankiller.com
    4. Re:code from scratch by sexconker · · Score: 1

      If security is a concern, you sure as hell better make it your area of expertise, then audit any code you intend to use (whether you write it or not).

    5. Re:code from scratch by Anonymous Coward · · Score: 0

      Always code from scratch. The time saved from complete understanding of your own code is hard to describe.

      Comment your code.
      Comment your code.
      Comment your code.

      Or else you'll revisit it in six months and wonder what the hell you were thinking when you wrote it.

    6. Re:code from scratch by Antique+Geekmeister · · Score: 5, Insightful

      If you want to write from scratch, write your own compiler and build your own system from melted glass. The time wasted encountering and solving a variety of problems already solved by others is very, very easy to describe, and there is little guarantee of even the limited success demonstrated by the best of the older code.

      The amount of time I've wasted arriving after some in-house project that one person wrote, everyone got stuck with, and needed to be ripped out and replaced with the standard open source tool when that one person got transferred away or they discovered its limitations the hard way would have given me a month off of work every year of my professional life. Chat clients may be the worst of the bunch: watching those harsh lessons relearned by every sophomore who just learned a new language and thinks the new language won't run into the same issues is in for big, big surprises.

    7. Re:code from scratch by plover · · Score: 5, Insightful

      Always code from scratch. The time saved from complete understanding of your own code is hard to describe.

      Well, that's certainly the least maintainable answer I've ever seen on the subject.

      If someone has to come along after you and maintain the system, how do they know what it does? Did you document it perfectly? Of course not -- you wrote it, you know how it works, so you'll invest nothing in educating others.

      When you use a library, framework, or a reusable whatever, not only do you get the functionality, but you get the available documentation and a potential pool of developers who are already familiar with that technology.

      I've seen an awful lot of NIH (Not Invented Here) syndrome in this business, and I've seen so many "look, I wrote my own string class, isn't it neat?" that I lost count. No, it's not neat. The STL has provided strings in C++ since 1994 -- if you're writing one in 2008, it's because you're so incompetent you don't know the full language. And the same is true for many of the major technologies. I'm not saying Hibernate is or was the best choice for your shop in this exact situation, but it was likely a better choice than writing your own.

      There's actually a solution that's kind of like a compromise, but offers some advantages: write a thin wrapper around the technology. You can either write a straight 1:1 wrapper, or create your own API, customized to be something you're comfortable coding against. You can then replace the technology with something better, when that something better comes along, and all you have to do is change the wrapper. The other reason this is a good choice is you can provide a mock object replacement for your API and run unit tests against it without bringing up an entire web environment.

      --
      John
    8. Re:code from scratch by AceofSpades19 · · Score: 5, Informative

      I write my own implementation of the c standard library and the C++ standard library too, because I find they are not efficient enough and I find using the standard libraries bite me in the ass too

    9. Re:code from scratch by E++99 · · Score: 1

      code from scratch - and reuse your own code - that way you know exactly what it can do and where you have to start from scratch

      Amen, brother. And be sure to document your work.

    10. Re:code from scratch by Joce640k · · Score: 1

      Yep. Don't re-implement basic stuff but write wrappers around it. That way you can change the underlying technology and the intermediate layer will save you from most of the pain.

      The intermediate layer also means you're writing to your own ideal API.

      caveat: This methodology isn't applicable to all types of programs.

      PS: For a couple of reasons I wrote my own string class but it's compatible with std::string so I can switch between them using a typedef.

      --
      No sig today...
    11. Re:code from scratch by Bodrius · · Score: 2, Insightful

      I think the anonymous coward may have been trolling with the unconditional statement, but there is a valid (if expensive) point there and I would suggest a different (additional?) compromise: if you really want that 'complete understanding' for a brand new problem, write your own prototypes from scratch. Then choose and reuse a mature, complete solution (or write your own only as a last resort).

      Wrapping an existing solution in your own APIs rarely teaches you much about the underlying problem - it helps in a lot of other ways, including experimenting / investigating solutions to reuse. But I think it misses the 'complete understanding' point.

      Writing a solution from scratch (even a bad / hacky solution) does give you a much better understanding which is extremely valuable for you - that's why we do that for the classic problems all the time in college, after all. Of course, no one should be writing their own C++ string class these days, but if you wrote your own string class *once*, it helps you to understand the implications when you use the STL or something else.

      But unless you are an academic, that's normally not what you are being paid for: you have a project to complete, and a specific problem to solve in the best possible way. Reusing a mature, tested solution is almost always simply in the best interest of the project - even if you do not learn as much as you would by writing your own.

      On the other hand, if the problem is different and tractable enough, hacking your own prototype from scratch can give you better understanding that is applicable to any 'real solution' you adopt - and if kept simple enough, can be used for unit-tests, benchmarks or other purposes.

      It's a matter of time and resources, but often enough prototyping your own wheel is well worth the investment - just use it as a tool to choose and apply the best solution for problems that are not well understood. Not as an excuse to risk the quality or cost of your project for the sake of pet projects and personal pride (which is often enough where NIH leads to).

      --
      Freedom is the freedom to say 2+2=4, everything else follows...
    12. Re:code from scratch by plover · · Score: 1

      Oh, I knew I was feeding a troll there. Yes, writing / prototyping something yourself can give you insight, but as you said that's more from an academic sense, and less from a business viewpoint. And that's great in college, and I expect those students to learn via pain -- it's a wonderful teacher. (Plus I don't have to pay for them to learn those lessons!)

      But TFA is all about a business decision, where a developer should be expected to know at least something about the available technologies in the problem domain. (I was kind of surprised he wasn't looking at iBatis, but that wasn't in the question he was asking.) Rather than writing his own data layer as a prototype, he'd be much better off writing little test harnesses to exercise Hibernate to learn how it works and to get some experience with its peculiarities.

      It's also difficult to know exactly when to give up on your prototype solution and switch to a supported package. I know I used to find it hard after investing a lot of time in a piece of code to just throw it away and bring in somebody else's library. These days, I look at that and say "well DAMN, there's an old chunk of code I don't have to maintain anymore." I now think of it as a bonus to use someone else's tested and documented code.

      For the most part, I find the bugs I encounter when using libraries like this come from my own incomplete understanding of the foreign API. Once I understand the usage patterns, though, things tend to smooth out fast.

      --
      John
    13. Re:code from scratch by GarryFre · · Score: 2, Informative

      Yep, I have this same issue with a current program. There is a constant clash between what the library the program was written to, and what the customer demands.

      Customers don't have a clue what is easy and what is hard.

      You can save a lot of time by thorough designing and specifying what the program is wanted to do.

      Using a library can often transform programming into a circus of porkbarrelers, where functions don't do simply one thing, they have side-effects, that can drive a programmer nuts.

      The thing is, that being off-target and having difficulties matching what the customer wants is a foregone conclusion in most jobs. It is extremely difficult to know what you might need of a program even 3 months down the line, let alone three years. Matching this moving target is like trying to shoot flies with a cannon, is going to take a lot of effort and its a never-ending job.

      Just be glad that you are not working for my customer ... No matter what terrible data eating, bug I find, no matter what I tell them about money they are letting slip through their fingers, they consistantly just come up with new "Emergency" features, the want yesterday and to hell with my concerns.

      Its exactly like being forced to add rooms to a burning building. I got to keep building so fast, I stay ahead of the fire, but oh God, what horrible results can happen when one is not allowed sufficient time for great coding, and are not allowed to fix new bugs.

      --
      www.Migrainesoft.com - Computer giving you a headache? We can fix that!
    14. Re:code from scratch by alexibu · · Score: 2, Interesting

      Yep. Write your own wrappers / interfaces.

      This has the effect of documenting exactly what you are using from the library. (Usually you will only be using a small subset of any library)

      The rest of your code can be written in an abstracted way. Like instead of instantiate an acme brand persistance object and call storeInXML on it every where in your code, just have a more abstract persist method, so the rest of the code doesn't even need to know how the stuff is being persisted

      You can substitute a simpler or instrumented version for unit testing.

      When you want to stop using the library for what ever reason (platform change, found a better way to get this functionality, different library, library licencing has changed etc) it is easy to see what needs to be changed, and the changes will not extend beyond one module

    15. Re:code from scratch by PJ+The+Womble · · Score: 1

      Might I quote from the old GBP 1 coin, after Newton? "Standing on the shoulders of giants".

      Except, of course, that one invariably meets one's programming predecessors for a couple of weeks in that nice new job before they go off to their own next little rung. Without wishing to offend anyone of the Pygmy persuasion, of course, and realising that this one works recursively about oneself too...

    16. Re:code from scratch by spectecjr · · Score: 1

      Did you document it perfectly? Of course not -- you wrote it, you know how it works, so you'll invest nothing in educating others.

      I always document my code perfectly. I used to be an assembly language programmer; I learned the hard way. That, and I've maintained others' code that didn't. Never will I foist that on someone else.

      The STL has provided strings in C++ since 1994 -- if you're writing one in 2008, it's because you're so incompetent you don't know the full language

      Or it's because you're working in a domain for which the STL implementation is not sufficient. Like, for example, games. Sometimes the generalized version sucks compared to a specialized one.

      --
      Coming soon - pyrogyra
    17. Re:code from scratch by smellotron · · Score: 2, Interesting

      I write my own implementation of the c standard library and the C++ standard library too, because I find they are not efficient enough and I find using the standard libraries bite me in the ass too

      You're moderated as Funny, but I can't tell if that was actually your intent or not. On a lot of embedded systems, a custom version of libc is used to "trim the fat" or to add system-specific optimizations.

      There are also those who fork the C++ library (or reimplement their own) because they're working in an environment that forsakes exceptions. Both the Google and Joint-Strike Fighter coding standards forbid exceptions in C++, which means libstdc++ as designed is a non-option.

      Performance-wise, it's not actually that hard to beat a general-purpose libc or libstdc++, due to their extreme flexibility/generality. In some environments, it might actually be justified.

    18. Re:code from scratch by smellotron · · Score: 2, Informative

      The STL has provided strings in C++ since 1994 -- if you're writing one in 2008, it's because you're so incompetent you don't know the full language.

      That's absolutely incorrect. There are a number of reasons why someone would want to avoid using the STL string as-provided:

      • if dynamic allocation is forbidden
      • if exceptions are forbidden
      • if templates are forbidden
      • if immutable strings are desired for their performance or safety characteristics

      These reasons may not apply to 99% of the programming community... but for the last 1%, this is critical.

    19. Re:code from scratch by try_anything · · Score: 1

      Always code from scratch. The time saved from complete understanding of your own code is hard to describe.

      Maybe you need to get better at understanding code you didn't write.

    20. Re:code from scratch by Anonymous Coward · · Score: 0

      It's all very well to re-use code, libraries, frameworks and whatever, but the piont is if you are not reasonably familiar with these before you incorporate them, you are using things you dont understand comepletely.

      For example you given the coding task of writing some wheel software.

      There are maybe dozens of existing wheel frameworks and libraries.

      time taken to understand 1 wheel library is say 1 month.

      time taken to code you wheel application maybe 2 months.

      if you go through ALL the exsisting code and undestand before deciding and the correct approash it takes 2 years before you even start!

      To some extent information overload, there is vast amoubnts of exsisting code in many forms. Howvere if you are not familiar with the use of a given lump of pre-existing code, or there are many pre existing lumps of code that may or may not suite your application, the time taken to get a reasonable understanding of the options dwarfs the time to re-invent the wheel.

      Frameworks can be particularly annoying as they often are great BUT, ie it does the vast bulk of teh area well unless you one one or two things diffenrent in which case it is useless. And learning enough of a framework these does of serious complexity and bloat can take a lot of time.

      Great Programmers know their limitations.

    21. Re:code from scratch by SL+Baur · · Score: 1

      reuse your own code

      I've done that on a couple of occasions, but the problem tends to be that you run out of code if you apply it to a proprietary code base (thus making your original code unreusable by you ever again).

      In recent years, I've tended to have been switched between different programming languages as well as different jobs/assignments so it hasn't been an option.

    22. Re:code from scratch by SL+Baur · · Score: 1

      Comment your code.

      Ah yes, comments are ALWAYS useful.

              # Loop over the words in the query
              #
              ARG: while (@args) {

      Better to write clear code in the first place and that particular bit of code does not need a comment.

      See _The Elements of Programming Style_ for how to write code and _The Mythical Man Month_ by Fred Brooks for how to manage a big project, but certainly NOT how to write code.

    23. Re:code from scratch by SL+Baur · · Score: 1

      Yep. Don't re-implement basic stuff but write wrappers around it. That way you can change the underlying technology and the intermediate layer will save you from most of the pain.

      Sigh. And hopeless confuse anyone who comes after you who has to maintain the bloody mess.

      When the OO fad finally dies, I'll be happy.

      Steve's Law - If a layer of abstraction is the right answer, you have probably asked the wrong question.

      (See my other posts under this article).

    24. Re:code from scratch by SL+Baur · · Score: 1

      I know that you wrote that as a joke and congratulations on your +5 funny, but I did that for real. Back in the early 80's, C (on the IBM PC under PC DOS) was often criticized because a one line printf("Hello World!\n"); often made a 50-100k executable because of all the run-time stuff it pulled in and I did a reimplementation of libc that turned that into something less than a 5k executable - portable to C Innovations C compiler and Lattice C, which later was purchased by Microsoft.

      Oh and I kept my rescue media (bootable 1.44M floppies) using libc5 instead of libc6 because I could make a tiny libc5 .so and thus be able to cram zsh as /bin/sh on the root file system. Could not quite fit nvi in, though I tried.

      Times, have changed ...

    25. Re:code from scratch by SL+Baur · · Score: 1

      Amen, brother. And be sure to document your work.

      No amount of documentation saves crap code.

      Think of the starving programmers who will be maintaining that code who must feed their children!

    26. Re:code from scratch by hobo+sapiens · · Score: 1

      I don't know if you're being sarcastic. But I recently started a new job in a place that is a huge java shop (coming from LAMP/ASP background). I am utterly amazed at the towers of abstraction layers that seem somewhere between a Rube Goldberg contraption and something out of a Dr Seuss book. Something seems wrong with requiring layers to help you manage layers. Hey, do you have too many layers to manage? Well, just use this tool (maven, hudson, cruise control, WICA) to help you manage the complexity.

      "Steve's Law - If a layer of abstraction is the right answer, you have probably asked the wrong question"
      I have been saying basically the same thing since I started working at this place.

      That said, OO seems to have some good tenets such as design patterns. So why is it that OO geeks seem to love piling layers upon layers?

      --
      blah blah blah
    27. Re:code from scratch by SL+Baur · · Score: 1

      I don't know if you're being sarcastic.

      No, I was quite serious. It's not often we get cool articles like this one, I do not often get a chance to discuss programming on-topic.

      That said, OO seems to have some good tenets such as design patterns. So why is it that OO geeks seem to love piling layers upon layers?

      It seems like a good idea at the time, especially to PHBs.

      I've been involved off and on, mostly on with "reusable" software projects at work for over 2 decades now. The only conclusion I've come to is that it sounds very, very good, but does not quite work out in practice.

    28. Re:code from scratch by AceofSpades19 · · Score: 1

      I was intending to be funny. Couldn't you just compile it with -fno-exceptions to not have exceptions in C++? I also don't really understand why Google wouldn't allow exceptions at all because exceptions are pretty useful

    29. Re:code from scratch by smellotron · · Score: 2, Informative

      Couldn't you just compile it with -fno-exceptions to not have exceptions in C++?

      You could, but it wouldn't work. For example, std::string throws an exception when you pass it a null pointer. If you simply set -fno-exceptions, it would happily ignore the throw statement, and try to copy data from the null pointer to its own buffer (Segmentation Fault). If you can't throw exceptions, it affects the software interfaces—you need to error codes or a global error state such as errno.

      I also don't really understand why Google wouldn't allow exceptions at all because exceptions are pretty useful

      They want their code to be universally applicable. Since some projects can't use exceptions (hard realtime, embedded environments, etc.), that means they simply put a blanket rule disallowing exceptions. If you do any C++ development, I would recommend taking a look at their C++ style guidelines. I don't agree with everything in there, but it's a very good read. Another decent read (much longer and more boring, but still full of insight) is the Joint Strike-Fighter C++ guidelines (PDF).

    30. Re:code from scratch by shutdown+-p+now · · Score: 1

      You're kidding, but at one place I worked (in the past, gladly!), we rewrote bits and pieces of STL ourselves to "improve performance". Personally, I had to do hash_map.

    31. Re:code from scratch by Anonymous Coward · · Score: 0

      It's actually kind of true. Games companies often have customized generics libraries that are hand rolled versions of the STL in order to make them faster.

    32. Re:code from scratch by Krishnoid · · Score: 1

      watching those harsh lessons relearned by every sophomore who just learned a new language and thinks the new language won't run into the same issues

      Which are ... ? Let some of us who are a bit more trainable learn from your hard-won experience. Or post it on Daily WTF. Either way.

    33. Re:code from scratch by Joce640k · · Score: 1

      I have a string with 128 chars pre-allocated inside it, if this buffer overflows it switches to dynamic allocation.

      The speed-up this gives when parsing text files (or anything else which requires a lot of temporary strings) is very noticable.

      Similarly, C++ file functions are designed around text, not binary data. If you read/write a lot of binary files you're far better writing some classes which are designed for the job.

      --
      No sig today...
    34. Re:code from scratch by zaphle · · Score: 1

      I've seen so many "look, I wrote my own string class, isn't it neat?" that I lost count. No, it's not neat. The STL has provided strings in C++ since 1994 -- if you're writing one in 2008, it's because you're so incompetent you don't know the full language.

      I should react to that. The stl string is one string implementation that uses the "string as array of characters" paradigm so that the algortihm template functions can be used with them. Other languages (C#, Java) use the "copy-on-write" paradigm (Google that up, I won't explain the difference here). The latter implementation is more memory and cpu-friendly in 90% of the cases where string operations are needed, so I prefer it above the stl implementation, therefore I DID write my own string class. (If ever I need to use stl algorithms on them, I convert my string into an stl string and afterwards back to my string class. This gives me additional deep copies, but hey, that's what the stl implementation does ALL the time with strings, whereas the other implementation only when the string changes, so there is your benefit.) Second thing (and even more important), the copy-on-write string is thread-safe, the stl not.

      Now how does this example adhere to this discussion? Sometimes, the existing code just doesn't float your boat. In such case, it makes sense to look for an alternative and often, writing it yourself can be a good choice as well. What is important when writing it yourself is to use class names and method names (and behaviour) that are well-established. In the case of my own string class, I used the method names of the C# string class, so my documentation is already written. Of course, you won't catch me re-writing things like the quicksort algorithm.

      Saying that someone who writes this or that class from scratch is incompetent is a dangerous statement that might somehow boomerang back in your face. Sometimes yes, sometimes no. Rule: listen to what the writer has to say for himself (or read his documentation), you might learn something, you might teach something. Or both.

      --
      And what if there's nothing behind the door until it is being opened?
    35. Re:code from scratch by Anonymous Coward · · Score: 0

      That's a strawman. You're assuming that someone who writes code from scratch will invest nothing in commenting / documenting it. This isn't necessarily true.

      Conversely, there are PLENTY of examples of code which is offered up for re-use which does lack comments and documentation. The Unreal Engine (UE3) is a great example from my industry.

      There isn't a simple answer to re-use versus code, however much you want to re-iterate general received wisdom on the subject.

      BTW STL strings are not "part of the language" and plenty of embedded implementations of C++ do not support them. Get a wider scope *then* call people out on bad practices. You're the one that's too incompetent to understand the language, as it happens. STL is a library, not a language feature. That's what the "L" bit stands for. (And don't get me started on the poor design of STL.)

    36. Re:code from scratch by TheLink · · Score: 1

      "So why is it that OO geeks seem to love piling layers upon layers?"

      Do the Python and Ruby bunch pile on layers and layers?

      I think the Java bunch tend to do that more.

      It may be because Java is too "stiff", so you need to have a lot more layers to get it to flex ;).

      I suspect many Java programs are actually half baked Lisp interpreters in disguise. The Lisp code being the huge XML configuration files.

      You should suspect something is up when a Java app's XML config files are the size of a typical Perl/Python/Ruby program that does a similar thing ;).

      Alternately it could be the Java programmers don't mind typing a lot - since Java is a verbose language it'll tend to attract more coders who like that sort of thing.

      I know Python programmers aren't that fond of typing - they even skip the braces ;).

      --
    37. Re:code from scratch by Anonymous Coward · · Score: 0

      +5 Funny surely ?

    38. Re:code from scratch by Anonymous Coward · · Score: 0

      I hope you are joking. Are you seriously claiming that it pays off to implement your own scanf for instance ?

    39. Re:code from scratch by Anonymous Coward · · Score: 0

      There is another advantage in not bothering to use others code. You not only know what your code can do, you also don't know what the other code can do and how your inferior implementation sucks.

    40. Re:code from scratch by Anonymous Coward · · Score: 0

      I write my own implementation of the c standard library and the C++ standard library too, because I find they are not efficient enough and I find using the standard libraries bite me in the ass too

      That would be because they are generally written for people who know what they are doing.

    41. Re:code from scratch by plover · · Score: 1

      The GP was claiming the person who writes the code from scratch should do so because "that way you know exactly what it can do", and that implies "I don't need to document it because I know it." Yes, you can write a good reusable module and document it, but then you pay for that documentation in addition to paying for the code itself. And you pay for ongoing maintenance on that code and documentation. It's expensive. With an external library or framework, that's one less chunk of code I'm worried about.

      And yes, I know the STL isn't in the language itself, and yes, most embedded systems have explicit proscriptions against dynamic memory allocation. I am not in such an industry and I do not have those restrictions, so I don't worry about it as much as others. But I want developers who know and embrace the STL because I don't want homegrown versions of simple, proven code anymore. The STL is a standard (that's what the "S" bit stands for :-) and should be used before any custom code is written. I am thoroughly tired of finding homegrown code because the developer didn't know better or had some misguided notion about the STL (possibly learned from an embedded background) that makes them think they need to write their own. I can point to two independent occurrences of this in our legacy code base today, and both have had bugs in their implementations that required maintenance efforts to go fix.

      Your arguments make sense in the corner case of an embedded system with non-standard requirements. Fine, I understand that. "Not standard" is a perfectly valid argument (one I occasionally like to trot out to justify my own decisions.) But in the case of a standards-based system where those restrictions don't exist, people who claim "Not Invented Here" are wasting time and money in the business world, and making the lives of the maintainers a nightmare.

      --
      John
    42. Re:code from scratch by AceofSpades19 · · Score: 1

      I was joking but some ass modded me informative instead of funny which I had a few hours ago

    43. Re:code from scratch by ckaminski · · Score: 1

      Your PS: I had similar needs for complex string parsing and manipulation not provided by std::string. But rather than extend and encode it with a new subclass, I created an Adapter for it, that would work equally well with an MFC CString or any framework that could degenerate to char* or wchar*

      Your string should be a string. Why introduce new behaviors to what is in effect a fundamental primitive?

    44. Re:code from scratch by Rary · · Score: 1

      Always code from scratch.

      Always ignore advice that begins with the word "always". ;)

      There is no "one size fits all" answer. There are arguments for and against coding from scratch in any given situation. A good developer evaluates all the options, weighs the pros and cons, and makes a decision that best suits their particular situation.

      Sometimes, the time saved from using a tried-and-true library that comes complete with documentation that not only you but other developers can use to achieve a complete understanding of the code, plus the ability to go to forums and get advice from others who don't even know your particular application but can still help solve your problems because they're working with the same library that you are, is hard to describe.

      --

      "You cannot simultaneously prevent and prepare for war." -- Albert Einstein

    45. Re:code from scratch by Anonymous Coward · · Score: 0

      The STL has provided strings in C++ since 1994 -- if you're writing one in 2008, it's because you're so incompetent you don't know the full language.

      Show me a person who claims to know the C++ language fully and I'll show you a liar.

    46. Re:code from scratch by Antique+Geekmeister · · Score: 1

      This is not the venue for teaching. I use patch submissions for new projects I like, and education in the workplace about already existing tools, and activity on developer discussion groups.

    47. Re:code from scratch by lamapper · · Score: 1

      I don't know if you're being sarcastic.

      No, I was quite serious. It's not often we get cool articles like this one, I do not often get a chance to discuss programming on-topic.

      That said, OO seems to have some good tenets such as design patterns. So why is it that OO geeks seem to love piling layers upon layers?

      It seems like a good idea at the time, especially to PHBs.

      I've been involved off and on, mostly on with "reusable" software projects at work for over 2 decades now. The only conclusion I've come to is that it sounds very, very good, but does not quite work out in practice.

      I also love your quote:

      Steve's Law - If a layer of abstraction is the right answer, you have probably asked the wrong question.

      I am pleasantly surprised to read this, perhaps I have not read the right forums...many times it seems people will select the newest greatest fad, tool, package, framework, etc... not because it is the best to get the job done, but because its new and they want to do something new and different.

      Than they leave the project and/or company and you are stuck with the mess they leave behind due to the choice they were able to get the manager to say Yes to.

      Even worse are companies that have the golden project mentality. When the new project gets proposed and run with, that project gets the lions share of the funding, literally anything and everything that they want whether its needed or not. When the project falters, it seems that the Director / Managers are the first to jump ship...if they can so they will not be held responsible for their poor decision.

      Even more amazing is those very same Managers are the ones that are in charge of the next Golden project.

      With one company, in less than 6 years I saw the same set of Managers start and jump ship from two different huge Golden projects (both failures). I was always amazed at how personal never seemed to look at the employee turn-over they caused and do something about them.

      I saw the company lose some very expert knowledge wise employees, however those managers never lost their jobs, even though the fault in both cases was easily partially their faults. When I finally gave my notice and left for greener pastures, those same managers were still there.

      I am not suggesting always firing someone when they fail as some companies do, after all any time I have failed it has always been one heck of a learning experience. One that I did not repeat I might add.

      At the very least, they should not be put in charge of the very next new project. Geez. The institutional memory at that place was amazingly bad.

      I have always maintained that if a Manager has abnormally high turnover rates, perhaps they might be part of the problem. But no one seems to monitor that or at least it seems like most companies do NOT.

      --
      Is your Internet Throttled? Install DD-Wrt, OpenWRT or Tomato to learn the truth! Google: 1Gbps/1Gbps: 5 Communities
  4. Why not use both options? by aurelianito · · Score: 5, Insightful

    AFAIK, you can access a DB via both JDBC and Hibernate. Just do most of the job with the frameworks and just the little bit that isn't supported use plain JDBC.

    1. Re:Why not use both options? by MBCook · · Score: 4, Informative

      Not only can you do that, if you want to keep things simpler (stay in the same transaction, for example) Hibernate can run native SQL queries in addition to HQL. You can code your own queries but still have the hibernate call return a full managed object that you can do the normal Hibernate magic on.

      --
      Comment forecast: Bits of genius surrounded by a sea of mediocrity.
    2. Re:Why not use both options? by syousef · · Score: 1

      AFAIK, you can access a DB via both JDBC and Hibernate. Just do most of the job with the frameworks and just the little bit that isn't supported use plain JDBC. ...or if appropriate another tool (eg. report generation tool).

      --
      These posts express my own personal views, not those of my employer
    3. Re:Why not use both options? by swillden · · Score: 3, Informative

      AFAIK, you can access a DB via both JDBC and Hibernate. Just do most of the job with the frameworks and just the little bit that isn't supported use plain JDBC.

      Actually, Hibernate gives you a range of options. You can:

      • Construct SQL queries and let Hibernate map the results into objects.
      • Construct SQL queries and get the results as arrays of scalars.
      • Bypass Hibernate completely and just operate on the raw JDBC connection. Just make sure you flush the session first if you're querying DB state that the session might have modified recently, and clear the session cache if your JDBC calls might have modified data that the session has cached.

      Hibernate is successful in large part because it gives you a lot of options, so you can adapt it to your needs.

      --
      Note to ACs: I usually delete AC replies without reading them. If you want to talk to me, log in.
    4. Re:Why not use both options? by timewasting · · Score: 3, Interesting

      Wow, someone who actually knows what they're talking about when posting here. That's kinda like someone RTFA.

      Hibernate is good by me, though I've enjoyed using Kodo/BEA/EJB3.0 in the past for OR mapping as well. Even old school JDBC in session beans is often good enough for most things.

      Personally I usually hate Spring IOC because all of the simple compile-time problems with typos and capitalization on imports turn into runtime configuration problems because those typos now exist in one of 500 random XML files (and the last one that you would think to look in). That and you often have a billion stupid interfaces with one and only one implementation class. Add to that NooB's who think everything has to be a session EJB with still another Facade EJB in front of it because they think Rod Johnson said it was supposed to be that way, and you realize that frameworks aren't necessarily going to make the architecture better, they just create more places for dumb developers to screw up (not that the original poster is doing that). Spring works well for developing a system that needs to support a lot of app server specific junk on multiple app servers (like LDAP single sign on stuff and JMX voodoo), multiple implementations of the same interfaces (like a product company writing client specific stuff), as well as for transaction management beyond pure JDBC transactions while running standalone JVM's outside of an app server. Almost no one needs that, so usually Spring is more hassle than it's worth. (particularly when trying to configure in Axis2 web services and other solutions that like to roll their own classloaders).

      Good software engineers know which competing frameworks to use, when each is appropriate for the assigned task, when to forego a framework and roll your own. Good architects know all of that, plus when the developer is designing a Rolls Royce when a Toyota is appropriate, which frameworks play well together, which is appropriate for the developers on the team both present and future, as well as when architectural decisions should be made, because switching frameworks or architectural refactoring midstream becomes insanely expensive and wasteful. Bottom line -- code reuse in and of itself may make the coding easier to implement and maintain, but having a sound architecture appropriate to the project is even more important. Just using Spring, hibernate, struts, axis, GWT or whatever flavor-of-the-week framework is popular and throwing together some junit and canoo tests doesn't mean that your solution doesn't flat-out suck. If anything, the richness of frameworks borne of the maturity of a language requires more wisdom and discernment, not less.

      As to the actual post itself -- It appears the dev isn't very familiar with the frameworks chosen, and needs to do a little digging in the mailing lists and doc. There's very few things that aren't possible with Spring/Hibernate with a little ingenuity. If the problems are with technical limitations of Spring Web Services such as WS-ReliableMessaging or WS-StandardOfTheWeek then use contract-first with Axis2. It's easy to swap it out.

    5. Re:Why not use both options? by beeradg · · Score: 1

      Seriously. What can't you do with Hibernate anyways? And who would actually want to write JDBC code? yuck.

    6. Re:Why not use both options? by julesh · · Score: 1

      Agreed. This is definitely the approach to take in most cases.

      I usually avoid Hibernate because it's overkill for most of my purposes -- I prefer beankeeper, which simplifies matters by having a *much* simpler transaction model and building its own db schema so you don't have to configure it to match your own -- but this is where Hibernate really shines. AFAICT, there isn't anything you can do with SQL but can't do with it.

  5. Subvert Hibernate? by Anonymous Coward · · Score: 1, Interesting

    Hibernate makes it very easy to write native queries for things that hibernate doesn't support well (e.g. bulk queries).

    I'm really curious where it's come up that you just can't live without JDBC.

    Most of the time a rewrite ISN'T the solution and should be avoided - no matter how tempting.

    Care to comment more on the problem? Lots of nerds have your attention.

    1. Re:Subvert Hibernate? by Bill,+Shooter+of+Bul · · Score: 1

      Mod up! There are only a few spots in which you would run into trouble with hibernate ( such as dealing with scaled out DB's*), I'd be really interested to see if you really hit one or not. I want to hear more about the alleged problem.

      *(I understand there is hibernate Shards, but I have some philosophical issues with that approach)

      --
      Well.. maybe. Or Maybe not. But Definitely not sort of.
  6. JDBC instead of Hibernate? by Anonymous Coward · · Score: 0

    If you think it would be better if you had used JDBC instead of Hibernate when you began coding your application, you are probably doing something wrong.

  7. Use JDBC *and* Hibernate by puppetman · · Score: 4, Insightful

    It's starting to look like I would have saved myself a whole lot of time if I had written the database transaction using JDBC instead of Hibernate

    Hibernate is great most of the time, but every Hibernate application I worked on had some JDBC somewhere, and I typically managed my own transactions... With regards to object-hydration, Hibernate (2.x) was an all or nothing, and sometimes I needed something in between for performance reasons.

    Obviously, I don't know the problems you face, but I am surprised that a flexible framework like Spring isn't meeting your needs, and that Hibernate is preventing you from using JDBC...

    1. Re:Use JDBC *and* Hibernate by Shados · · Score: 4, Insightful

      This is indeed the best advice. No framework will ever meet 100% of requirements. So you either use extensible frameworks, or have a facade that allow you to pipe logic either through the framework, or through custom code, as needed, allowing 90%+ to go through the framework, and the last 10% to go through whatever you wish.

      A lot of ORMs (I'm not as familiar as I wish I was with Hibernate) will allow you to use the standard dynamic SQL generation, AND to do stored procedure wrapping and projections... With that, you seriously can do pretty much "anything", except for using the very very latest features of the very very latest version of your RDBMS of choice, such as unsupported datatypes. For the 2-3 queries in the entire app that ends up in that situation, you simply have a custom data manipulation layer (small, not very heavily architected), and both that and the framework just sit behind whatever abstraction facade one may have...

      I also agree with the other part of the advice.... Spring not being powerful/flexible enough? When you have what is basically a "meta-meta-meta-meta-extensible framework" (which is basically what Spring is), its hard to see that something could possibly need features that cannot even be met using all of Spring's extension mechanisms...

    2. Re:Use JDBC *and* Hibernate by ozphx · · Score: 1

      I was under the impression the transaction support in Hibernate was more than sufficient for most purposes. I come from a .Net background so most of my experience is using the NHibernate port with the Diamond Binding active record implementation. In this, using transactions is as simple as using(new TransactionScope()) { ... }.

      Any complex queries can be handled using HQL (including aggregates, etc, if you are feeling really manly), and if you really need you can get the connection and use ADO (similar to JDBC) for hitting sprocs/whatever, in the same transaction.

      So I agree with parent, I think OP needs to read up on his framework more. Hibernate can be fairly intimidating, but this makes it quite flexible (difficult for clustering though, but I guess theres always Shards). The main reason we went with Diamond Binding is because it simplifys things down a fair bit (and gets rid of those pesky mapping files) which helps the junior devs a fair bit.

      --
      3laws: No freebies, no backsies, GTFO.
    3. Re:Use JDBC *and* Hibernate by Anonymous Coward · · Score: 0

      Reusing is obviously the best start for a prototype. But its not all about Reusing vs Recoding : you can also modify the reused code. Thats where free software becomes really an advantage.

      Lots of time you will find that the internal API of the framework you are using is too limited, but you can adapt it for your own needs with very few modifications.

    4. Re:Use JDBC *and* Hibernate by Anonymous Coward · · Score: 0

      Agreed. Most of the time when people complain that Hibernate + Spring isn't meeting their needs, it's because they haven't taken the time to try to understand:

      1. How the two frameworks work
      2. How the two frameworks work together

      I've seen a lot of beginners run into problems with lazy initialization when using JTA + Spring's HibernateTemplate - simply not understanding how transactions relate to Hibernate sessions. And likewise goes for not using HQL and even native SQL appropriately. Taking the time to understand the tools is time much better spent than trying to rework the application from scratch.

    5. Re:Use JDBC *and* Hibernate by rfreedman · · Score: 1

      Indeed. Especially with the Spring/Hibernate combination. Spring provides JDBCTemplate, which does for JDBC what HibernateTemplate does for Hibernate.

      There's absolutely no reason that you can't use both HibernateTemplate and JDBCTemplate, even in the same transaction.

  8. When in doubt rewrite it by WarJolt · · Score: 0

    It's better to use the new library. Who know what new features you'll need later. Plus everything you've learned the first time around can be written cleaner and perhaps more modularly the second time around, so substituting pieces of code will be easier.

    1. Re:When in doubt rewrite it by Anonymous Coward · · Score: 1, Insightful

      This is bad advice.

      A system that has been tested for years will almost always be better than something new you've rewritten. Remember that it's more than a developer's resources you're using and no developer writes pristine code.

      I've seen many projects that other programmers have said just absolutely need a rewrite and it's never ended well. Usually, they end up with more problems than they started with.

      If you really need to sanitize the code base, wrap the old stuff. I've had much success with this

    2. Re:When in doubt rewrite it by SL+Baur · · Score: 1

      I've seen many projects that other programmers have said just absolutely need a rewrite and it's never ended well. Usually, they end up with more problems than they started with.

      I tend to agree, but ... it depends upon how you go about doing it. I'm "rewriting" core code right now in my project, but it's more or less algorithmic changes I'm doing and being careful and keeping the original code working as I'm transforming it means I can do regression testing every step of the way.

      If you really need to sanitize the code base, wrap the old stuff. I've had much success with this

      If the base algorithm is wrong and/or too limited to permit optimization (and if we get things wrong, the code will take hours if not days to complete) "wrapping" things will not make a bit of difference.

      (Serious question) What do you do with long-lived code that has several layers of wrappers in it? (Serious question #2) What do wrappers have to do with fixing core code that may be unreadable 600+ lines of nested if/elses (see the emacs core for plenty of examples of this).

      "Don't patch bad code, rewrite it" is a guideline out of _The Elements of Programming Style_ and one I absolutely believe in.

  9. How about contributing to OSS by michaelepley · · Score: 1

    Assuming your employer allows it, why not take the time you might have spent recoding and contribute and add the features you need to some of the frameworks/toolkits you are using?

    1. Re:How about contributing to OSS by phyrz · · Score: 1

      *ding* this is the correct answer.

      --
      Don't point that gun at him, he's an unpaid intern!
    2. Re:How about contributing to OSS by Canberra+Bob · · Score: 1

      Generally the conversation would go something like:

      you: hey boss, can I improve Hibernate to do what we need it to do on this project and contribute the changes back to the project?

      boss: sure, as long as you finish this project first and don't do any of that during work hours you can contribute back whatever you want.

    3. Re:How about contributing to OSS by ozphx · · Score: 1

      Generally its going to be more efficient for the people that know the codebase to do it. The employer will be better off paying the maintainers to do it.

      --
      3laws: No freebies, no backsies, GTFO.
  10. Wrong Question by pete-classic · · Score: 5, Insightful

    You should be asking, "Should I make architectural decisions before or after I collect all the requirements." But you know the answer to that one.

    A more experienced engineer would have dug for requirements early, planned for some creep, and would have warned the manager that the risk of starting before the thing is properly speced is that all work might have to be thrown away.

    You'll know next time.

    -Peter

    1. Re:Wrong Question by chromatic · · Score: 3, Insightful

      A more experienced engineer would have dug for requirements early....

      Seriously, has that ever worked for you? (I assume you don't work on space probes.)

    2. Re:Wrong Question by syousef · · Score: 4, Insightful

      You should be asking, "Should I make architectural decisions before or after I collect all the requirements." But you know the answer to that one.

      That's harsh. I've seen the business change it's mind to the point that all that was kept was the project name (and wonder why it couldn't be delivered on time). I've also seen changes driven by legislation or changing business conditions that could not have been predicted. You can't dig for what ain't there. What you're asking him to do is be a fortune teller. The best he can do is try to improve relations and communications with the business, and let them know that the more things change at requirements level, the more time will be required.

      --
      These posts express my own personal views, not those of my employer
    3. Re:Wrong Question by Sloppy · · Score: 2, Insightful

      In the real world, you never "collect all the requirements." That's just plain impossible.

      --
      As copyright owner of this comment, I authorize everyone to defeat any technological measure which limits access to it.
    4. Re:Wrong Question by CorporateSuit · · Score: 3, Interesting

      would have warned the manager that the risk of starting before the thing is properly speced is that all work might have to be thrown away.

      One thing that is not taught in schools but learned "on the battlefield" is the instincts of when a project is going to go bad before it starts. You can simply smell it on the proposal or project schematic.

      Until that's developed, you have to live with damage control. I always suggest to new guys, who deal with management or clients, what I used to say when something like this would happen: "Sure, it can be done, but we'll have to extend the deadline a few (days/weeks/months), and it will be expensive to add that since we'll have to change our [blah blah blah, you said the word 'expensive' so they're no longer listening. They're thinking. Once their eyes refocus, stop talking and ask them for their final decision]."

      They don't care how difficult it is or how many bugs will be introduced by cramming foundational changes in at the last second. They care about deadlines and money. You tell them that both will be sacrificed for some unneccessary feature creep, and you'll start seeing some managerial decision making instead of simple managerial delegation.

      --
      I am the richest astronaut ever to win the superbowl.
    5. Re:Wrong Question by pete-classic · · Score: 0, Redundant

      They care about deadlines and money. You tell them that both will be sacrificed for some unneccessary feature creep, and you'll start seeing some managerial decision making instead of simple managerial delegation.

      Well said.

      -Peter

    6. Re:Wrong Question by pete-classic · · Score: 3, Interesting

      Sure. There are always going to be eleventh hour changes. But generally speaking, a reasonable requirements miss isn't going to cause a database architecture to go from being the best choice to making the project impossible. That's a huge miss that is partially the developer's fault.

      Maybe I'm wrong, but this sounds like a clear case of cowboy development to me. Maybe it wasn't, but this is what cowboy development gets you in any case. If he keeps doing the same things he's going to keep getting the same results.

      -Peter

    7. Re:Wrong Question by pete-classic · · Score: 4, Interesting

      Has digging for requirements ever worked for me? I'll say! You must be doing it all wrong!

      Maybe I don't understand your question. Are you asking if digging for requirements has turned every project I've touched into a paragon of ahead-of-schedule under-budget success? Certainly not.

      But I have headed off innumerable problems by asking probing questions, clarifying what the customer wants (in his head and mine) and, thereby, minimizing dead-ends and unacceptable implementations.

      And sometimes I get slapped down. And sometimes that causes over-runs and schedule slips. And when that happens I know that I've done my job . . . and I make sure my boss knows it, too.

      Never worked on space probes, but I have worked on satellite set top boxes!

      -Peter

    8. Re:Wrong Question by E++99 · · Score: 2, Insightful

      You should be asking, "Should I make architectural decisions before or after I collect all the requirements." But you know the answer to that one.

      A more experienced engineer would have dug for requirements early, planned for some creep, and would have warned the manager that the risk of starting before the thing is properly speced is that all work might have to be thrown away.

      I disagree. An experienced engineer would know that he never has all the requirements, and the no spec ever encapsulates every real need that will be realized. Therefore, every project must be built with the assumption of future change and growth.

      The is exactly the problem of the overuse of frameworks like Spring and Hibernate. They too frequently introduce unnecessary complexity and limitations.

    9. Re:Wrong Question by chromatic · · Score: 1

      But I have headed off innumerable problems by asking probing questions, clarifying what the customer wants (in his head and mine) and, thereby, minimizing dead-ends and unacceptable implementations.

      Before you drew one little box or cloud on a whiteboard as part of the design process? Before your customer had a prototype to say "Oh, I don't like this at all"?

      Are you asking if digging for requirements has turned every project I've touched into a paragon of ahead-of-schedule under-budget success?

      No; I believe that ahead-of-schedule and under-budget have very little to do with success, unless there's no way in which you can delight the customer. In that case, I've seen projects cling to the budget and schedule, so they'll have delivered something.

    10. Re:Wrong Question by mveloso · · Score: 2, Insightful

      Well, that's the wrong question as well. Only in highly structured environments can you collect all the requirements. And in those highly structured environments (ie: government, military, public safety) how many software projects come out meeting the requirements, are on time, and on budget?

      The answer is probably very small. In fact, I'd guess that the only things that a highly structured development process gets you over a fast, iterative and mostly loose process are (1) CYA material, (2) aggravation, and (3) consulting dollars. You get #2 with any development process, but at least in a structured process you aggravate everyone else as well.

      In any piece of software there comes a time when what you built doesn't fit so well with what your customer is asking for anymore. Lucky for you it happened sooner rather than later.

    11. Re:Wrong Question by dbIII · · Score: 1
      Software is seen by many as "easy" which is why requirements frequently change. The end result is that most software bears no more relation to a planned engineering project as does basket weaving. It also means that those things that actually should be easy often are not.

      Thus I think the answer to the whole question is the hard one of when do you throw things out to meet changed requirements.

    12. Re:Wrong Question by shaka · · Score: 1

      You should be asking, "Should I make architectural decisions before or after I collect all the requirements." But you know the answer to that one.

      Yes. "Not at all".

      Steve Yegge: Business Requirements are Bullshit.

      Worth a read.

      --
      :wq!
    13. Re:Wrong Question by Anonymous Coward · · Score: 0

      When was the last time you where on a project with a fizzy requirements that were on-time and on-budget and on-spec? On-spec might be a bit hard since you don't know the requirements.

      Serious guys, this is not rocket science, there have been formal methods for over half a century that are perfectly applicable for whatever mess you might encounter in the future. You could even argue two millennium's if you include common sense as practiced by earlier philosophers.

    14. Re:Wrong Question by chromatic · · Score: 1

      There have been formal methods for over half a century that are perfectly applicable for whatever mess you might encounter in the future.

      Have you ever personally seen those work on any project?

    15. Re:Wrong Question by jesterzog · · Score: 1

      That's harsh. I've seen the business change it's mind to the point that all that was kept was the project name (and wonder why it couldn't be delivered on time). I've also seen changes driven by legislation or changing business conditions that could not have been predicted.

      I agree, but it does sound as if the submitter's feeling some kind of responsibility for decisions that were made... as if re-using or coding from scratch might have actually made a difference. The only way you could have known that from the start is if you knew enough detail from the start. Perhaps it could have been possible to probe for more, or maybe it wasn't there.

      I've been involved in a project which had some complicated statistical uses. The customer expressed them in terms we could understand (as developers) and we communicated back exactly what we were doing. Because it was pretty new stuff, though, they really only figured out half way through that quite a radical change was needed which had a severe effect on our beautiful architecture and introduced all kinds of complications for working with the existing code-base.

      It could easily just be a communication issue with saying "too bad" to the customer, and giving them the choice of the original requirements, or scutlling 75% of the work to start again. (And then would it happen all over again?) What's really important, though, is both that they understand the detail of exactly why this has to happen, and that they're helped to provide useful and more-likely-correct information the second time around. For us, neither was an option and we ended up just putting in a couple of icky hacks which make the code less maintainable and probably less memory/speed efficient than it could otherwise be, and the customer was accepting of this.

      Rather than asking whether it's better to re-use or not to re-use, it sounds to me as if the submitter should be asking about whether it would have made sense to spend more time gathering requirements at the beginning or not. There's not really enough information provided to determine this, however.

    16. Re:Wrong Question by julesh · · Score: 1

      You should be asking, "Should I make architectural decisions before or after I collect all the requirements." But you know the answer to that one.

      A more experienced engineer would have dug for requirements early, planned for some creep, and would have warned the manager that the risk of starting before the thing is properly speced is that all work might have to be thrown away.

      You'll know next time.

      Strongly disagree. Collecting enough of the requirements before the project begins to do this is almost impossible in most cases. There's a very high chance that the OP would never have found out about the requirements he now faces if he didn't have a working first release deployed already. Users never know what they want to do with software until they have it in front of them, that's just a fact of life, and no amount of requirement gathering can fix it.

      It is also nearly always possible to build the project one requirement at a time without having to throw away more than a small fraction of what you write. Architectural decisions should be made when a requirement dictates them. If Hibernate and Spring made the OP's job easier for the first version, using them was the right choice. If he's done a halfway competent job, replacing them now shouldn't be any harder than doing the work without them in the first place would have been.

    17. Re:Wrong Question by Dr.+Hok · · Score: 1

      Sure. There are always going to be eleventh hour changes.

      The point is that the customers usually doesn't know their requirements themselves. The ask you for this and that, but only after seeing the first prototype they realize that it is not exactly (or even not at all) what they wanted.

      And this is not an exception. At least in my experience. We had wasted a lot of time and money trying to analyze everything, most of it in vain. Then we went agile, showing prototypes as early as possible, which always cuts a lengthy, fruitless analysis short.

      --
      Say out loud: I'm an Aspie and I'm somewhat proud, I guess. Uh. Can I write an email in all caps instead? Hm...
    18. Re:Wrong Question by Lonewolf666 · · Score: 1

      You should be asking, "Should I make architectural decisions before or after I collect all the requirements." But you know the answer to that one.

      Sure.

      You collect all the requirements as they stand at day X. The you start planning and coding. Once you have invested significant work, say on day X + 20, the requirements change. Repeat every 20 days.

      Now, do you tell you manager each time that you have to restart the project?
      Or do you try to meddle through, reusing as much of your existing code as possible?

      --
      C - the footgun of programming languages
    19. Re:Wrong Question by Anonymous Coward · · Score: 0

      Just like you CANNOT prepare for every requirements change/creep you also CANNOT see into the future.

      You are disillusioned if you think you will cater for all possible changes or requirement changes.

    20. Re:Wrong Question by Aladrin · · Score: 1

      Wait, you don't ask questions of the customer before you start designing? You just take whatever they give, ask -no- questions, and plan it all out? THEN you go back and ask the customer if that's what they wanted?

      That would be a nightmare.

      Nothing will stop the customer from changing their mind about what they want, but getting enough information ahead of the planning stage will save you a world of hassle later.

      --
      "If you make people think they're thinking, they'll love you; But if you really make them think, they'll hate you." - DM
    21. Re:Wrong Question by pete-classic · · Score: 0, Offtopic

      Before you drew one little box or cloud on a whiteboard as part of the design process? Before your customer had a prototype to say "Oh, I don't like this at all"?

      What are you talking about? The point was about being locked in by design choices. My comments were in the context of the original "ask slashdot", not whatever was going through your head when I made them. So, no, not before the first whiteboarding, but long before marrying an object model framework that squeezed all the air out of the project.

      And, yes, part of being an expert is being out ahead of the ball. If you aren't asking your customer questions that he hasn't even considered then what does he really need you for? He could just get some college kids to code the thing up if it is fully realized in his mind.

      I believe that ahead-of-schedule and under-budget have very little to do with success, unless there's no way in which you can delight the customer.

      Well, they have everything to do with success if you're, you know, running a business. Delighting the customer is a laudable goal as well, but little comfort if you have to close the doors.

      -Peter

    22. Re:Wrong Question by mounthood · · Score: 1
      I'm a programmer not a manager.

      They care about deadlines and money. You tell them that both will be sacrificed for some unneccessary feature creep, and you'll start seeing some managerial decision making instead of simple managerial delegation.

      It always bugs me to see "answers" like this because all it really says is "do their job for them."

      No working programmer can deny the practicality of what you suggest to new guys, but if I wanted to be a manager I'd apply for the job.

      --
      tomorrow who's gonna fuss
    23. Re:Wrong Question by Calyth · · Score: 1

      I don't necessarily agree that an engineer should set the requirements in stone before coding. Although proper planning is a must, having the flexibility to deal with changing requirements is probably more useful.

      Remember, clients are whimsical people who don't know anything about software development, or the technologies (and the associated limitations) that you'll be using. And they don't really care what problems you'll run into. They want their problems solved, and you're the one to fix it.

    24. Re:Wrong Question by CorporateSuit · · Score: 1

      I'm a programmer not a manager. It always bugs me to see "answers" like this because all it really says is "do their job for them."

      As a programmer, it's completely within your job description to raise concerns to your manager when they tell you to add/remove something that will cause long-term system instability or delayed software. You're still letting them do their job in making the final decision, but it's your job to make sure their decision is informed. Don't be afraid to make your life or job easier by washing blood off your hands and onto his. You can only make him responsible for the negative impact of his decisions if you let him know what those negative impacts will probably be. Otherwise, you can stay quiet, head down, in the dark, and then you can enjoy your forced overtime, minimum wage, and unemployment lines. You help the guy out enough and you can expect to be getting more money for less work without leaving the comfort of your company, and your manager will treat you like a golden child.

      --
      I am the richest astronaut ever to win the superbowl.
    25. Re:Wrong Question by CodeBuster · · Score: 1

      They care about deadlines and money.

      Those two words do usually get their attention.

      You tell them that both will be sacrificed for some unneccessary feature creep, and you'll start seeing some managerial decision making instead of simple managerial delegation.

      They may make a decision, but that doesn't mean that you will be happy about it. They might decide, for example, that they don't like your estimate or analysis of the situation. They might decide that you are simply a stubborn "techie" who is standing in the way of their grand business strategy and doesn't appreciate the larger business picture. So instead of dropping the feature because the sales people have told them that a competitor already has that feature and no feature = no sales going forward, they find themselves a new "techie" who agrees with them and is willing to be a "yes" man for management. It is the old adage, if you don't like the opinion of the expert then find yourself a new expert (it worked for decades with the tobacco industry, it works with the global warming deniers, and it works for technical projects too). If you oppose management often enough and always end up on the "wrong side" of debates then you may become a tempting target when it is time to cut some people loose for arbitrary reasons (bad quarter, economy is down, a tough competitor is making life difficult, etc). Sad but true.

    26. Re:Wrong Question by Joey+Vegetables · · Score: 1

      One thing that is not taught in schools but learned "on the battlefield" is the instincts of when a project is going to go bad before it starts. You can simply smell it on the proposal or project schematic.

      I'm the guy who gets those projects that everyone knows are going to go bad before they start, you insensitive clod!

      Seriously . . . I have a reputation for being able to pull off some of these nearly impossible types of projects. I've learned some skills that help me to do that. One of them is the ability to smell a bad or inappropriate tool, framework, design, or architecture. It's not that hard. If it helps you to follow the principles of KISS (Keep It Simple, S******d) and DRY (Don't Repeat Yourself) then it is probably good and appropriate. If it makes it more difficult or even impossible to do so, then it is inappropriate and/or bad.

      Generally, I've avoided other people's frameworks when possible. I've tended to find them more trouble than they are worth. I don't find it particularly difficult to write code that will write good SQL for me, or to navigate between the relational and object worlds without confusing the two (partly because I have DB design background). I don't have a problem refactoring as I go, or creating sufficiently flexible designs that most requirement changes don't break them.

      But I don't feel any particular need to reinvent things like languages, file formats, database engines, or operating systems. There are great choices out there to meet most any need, most of them Open Source, and I make a point to leverage them where possible.

      I guess it boils down to this . . . I don't feel a need to reinvent a wheel, if it is truly round. But I also don't feel a need to re-use a "wheel" that actually is shaped like a square, and that requires special roads in order to run. If I encounter one, I immediately find a way to re-pave the road, if I can, so that a normal wheel would suffice, and if I can't, then I write an abstraction layer of my own, complete with inertial dampers, gyroscopes, and whatever else is needed, so that the rest of the code can exist just as if it did have a functional wheel and road to depend on. :)

    27. Re:Wrong Question by chromatic · · Score: 1

      That would be a nightmare.

      No, that's a false dilemma.

      Nothing will stop the customer from changing their mind about what they want, but getting enough information ahead of the planning stage will save you a world of hassle later.

      That depends on what you mean by "enough". In my experience, the type of people which believes that "enough" is possible often tends to lock customers into "what you told me before I started designing".

    28. Re:Wrong Question by mounthood · · Score: 1
      My manager is great; I wasn't trying to bitch.

      As a programmer, it's completely within your job description to raise concerns to your manager when they tell you to add/remove something that will cause long-term system instability or delayed software. You're still letting them do their job in making the final decision, but it's your job to make sure their decision is informed.

      The point I wanted to make is that there was a time when being a manager meant more then being the arbiter of the budget. Managers used to know about the job/process/work they managed. That's less the case today, and in IT it's almost non-existent. The reason we have to explain the financial and deadline impact is because they don't know.

      --
      tomorrow who's gonna fuss
  11. Great programmers... by Anonymous Coward · · Score: 0

    reuse great code.

  12. This question isn't about reusing code... by gdeciantis · · Score: 3, Interesting

    Ok first, reusing code is very important. You can get a lot of gains out of code you can borrow/steal from some other place. BUT, code you can't change is rigid (by definition) and will make your life difficult. We used hibernate for one of our projects and I am regretting that decision as well because it brings its own host of bugs that are impossible to fix unless you know how to alter the hibernate code, which means you need to merge with the main branch, but then you must get approval, and the cycle is really awful. If we had built an abstraction between us and hibernate we could swap it out for another ORM technology, possibly even a homegrown one. Would I write that abstraction layer twice, probably not. Would I replace hibernate with something better, absolutely. That may not mean I build it myself, I might buy it from someone and that is a whole different kind of question which is much much harder. So should you reuse code, YES. But only if it is well tested code that you change if you need to. If it isn't, then you should be able to swap out what you grabbed for something better.

    1. Re:This question isn't about reusing code... by Anonymous Coward · · Score: 0

      You should have built in the abstraction layer from the beginning, regardless. That's why things like OOP, OOD, TDD and dependency injection exist. So that you can create another implementation later if you get backed into a corner.

      Great programmers do that.

    2. Re:This question isn't about reusing code... by Anonymous Coward · · Score: 0

      Well, at least today you can use JPA and swap out Hibernate for TopLink, EclipseLink, or KODO as you see fit.

    3. Re:This question isn't about reusing code... by jcoleman · · Score: 1

      Hibernate brought you a host of bugs b/c you didn't understand it. ORM is a notoriously complex domain. There is nothing better than Hibernate for ORM. JPA is a subset of what Hibernate offers - without Hibernate there would have been no JPA.

  13. Understanding the code is decisive by Anonymous Coward · · Score: 0

    If you must "open the black box", and get into the entrails of some rat nest of logic to complete your project, then trying to tweak code you don't understand is a sure-fire time waster, and chances are you'll have to rewrite it later anyway.

    Only if the code is clear to you then can go ahead and use it. Only you can answer that question.

  14. Well.. by somersault · · Score: 1

    If you separate out your database code from the interface code then it would make things a lot simpler when it comes to changing the back end.. it shouldn't matter whether you've written it yourself or been using libraries because you'll only have to make changes in one place, and it should be easy to fire through it without too much hassle (unless you're switching to a new database system that has specific SQL quirks in date handling/binary blob handling or that kind of thing).

    Personally I've never gone with frameworks though. With each project I work on I try to learn from past experiences to make my code even more modular. I've also been working on web apps with a lot of feature creep recently.. if you don't manage to keep everything simple it quickly becomes a mess keeping track of the changes.

    --
    which is totally what she said
    1. Re:Well.. by syousef · · Score: 1

      Personally I've never gone with frameworks though.

      Yes you have, unless you've written everything down to the database driver and comms layer. You just don't seem to understand that you've chosen a layer at which to employ a framework. JDBC is a framework too.

      --
      These posts express my own personal views, not those of my employer
    2. Re:Well.. by mini+me · · Score: 1

      I believe you are touching on the answer here. The model is a black box. The rest of the application doesn't care if you are using Hibernate, JDBC, or your own home grown database layer. There should be no reason why a model cannot use all of those things at the same time, even.

      Add the methods requiring JDBC to your model and you are done.

    3. Re:Well.. by somersault · · Score: 1

      Yeah, I guess I was thinking more about 'patterns' than 'frameworks'.

      --
      which is totally what she said
  15. agreed by nimbius · · Score: 1

    lock in the requirements early, damage control the creep, and make sure your meeting attendance roster doesnt start including more useless management than is really necessary. ive been screwed by managers from departments ive never even heard of before.

    --
    Good people go to bed earlier.
  16. Both by Art3x · · Score: 0

    A little of both. Portion size is key. I search for functions and classes but not whole frameworks.

    For example, as a web programmer, I love jQuery, to simplify my JavaScript. And sometimes I copy a PHP function or class when I need to do something complicated, like translate HTML to wiki mark-up.

    But the requirements for each project is so irregular that customizing a one-size-fits-all PHP framework would be the same amount of work yet result in all this extra code, I think.

  17. If you can reinvent the wheel, that is a way by CrazyJim1 · · Score: 1

    You have two choices: Read someone else's code and documentation, or write it yourself. Sometimes the act of learning someone else's code is almost as much work as writing the stuff yourself. The nice thing about writing the code yourself is easier to modify, and extend. The act of writing code makes you remember what you did whereas learning someone else's code doesn't always let you remember every nuance. I catch slack from my friend who disagrees with me, but whenever I have the ability to code something that someone made a library for, I typically code it myself.

  18. Meh by Anonymous Coward · · Score: 0

    Just duct tape them together with some Perl.

  19. What's up with slashdot lately by 1155 · · Score: 4, Insightful

    I don't get it. About 2 years ago this post wouldn't have even been front page worthy, and now we have this? If I wanted to use slashdot as a howto forum, I wouldn't be looking here. I just don't get it, why would a post list this make it to front page? It's for nerds, but it doesn't matter except to a small minority, and it's not news.

    Or am I missing something?

    1. Re:What's up with slashdot lately by geekoid · · Score: 2, Insightful

      Apparently you weren't here 2 years ago. These kind of question have been appearing on the front page for 10 years.

      --
      The Kruger Dunning explains most post on /. http://en.wikipedia.org/wiki/Dunning%E2%80%93Kruger_effect
    2. Re:What's up with slashdot lately by Anonymous Coward · · Score: 0

      Yes, you are. About two years of Slashdot apparently.

    3. Re:What's up with slashdot lately by Anonymous Coward · · Score: 0

      Slashdot has always sucked. It just sucks more and more as it ages. Even the trolls don't bother with it any more. And that's really sad.

    4. Re:What's up with slashdot lately by Anonymous Coward · · Score: 0

      It's news because someone on Slashdot is finally admitting that ORM products like Hibernate are not the end-all be-all of database access methodologies and that they might have to either:

      1. Understand how to access their database without dumbing it down via Hibernate.
      2. Hire a fucking DBA or DBDev who knows what they're doing with the db.

      Plus it's news because some Hibernate-oriented person is admitting they're wrong. That almost never happens.

    5. Re:What's up with slashdot lately by Anonymous Coward · · Score: 0

      You are missing something. Slashdot has jumped the shark. It has peaked and gone off to join the Choir Invisible. It is a mere shambling zombie of it's former self. I quit posting under my (5 digit) userID two years ago. Now I come back once a quarter to read the front page, sigh, then move on to something that matters. It's nostalgia, mostly. But you really can't go home again.

    6. Re:What's up with slashdot lately by blank+axolotl · · Score: 5, Insightful

      it doesn't matter except to a small minority

      Then why are there over 200 comments, more than usual? Good programming practice is an interesting topic for many of us.

    7. Re:What's up with slashdot lately by SL+Baur · · Score: 1

      Or am I missing something?

      Yup. It's a programming article and interesting to many of us.

      You're not +5 insightful (as I see the moderation right now). If you did not like the topic it was your choice to read it and respond to it.

    8. Re:What's up with slashdot lately by Anonymous Coward · · Score: 0

      Where can I find a howto forum?
      These questions are not about using a specific language or a specific DB. These questions are about proper programming practices. Which better place to ask than a website visited by code gurus...

    9. Re:What's up with slashdot lately by johannesg · · Score: 2, Funny

      it doesn't matter except to a small minority

      Then why are there over 200 comments, more than usual? Good programming practice is an interesting topic for many of us.

      Maybe it is just a boring day? Nothing of interest happening in the world?

    10. Re:What's up with slashdot lately by Xest · · Score: 1

      Yep you're definitely missing something. Many people here are developers and getting this guys questioned answered is only a small part of why these types of news postings are excellent.

      The opportunity for developers with countless different backgrounds to answer it in their own way and hence share knowledge between developers is why news postings like this are great.

      Reading through the threads improves all of our knowledge because no single person has the same experiences to learn from as anyone else. Taking in other people's experiences makes us all better developers.

      Developers are absolutely not just a small minority of the Slashdot crowd, I'm pretty certain the vast majority of people here have at least some development experience even if it's not in a professional capacity.

      Ask Slashdot responses have a much greater amount of useful and insightful responses for people ofe all competences than Political, Apple and Gaming stories to name a few. I'd much rather have the insightful comments provided in response to Ask Slashdot queries to read through than the pro-Apple/anti-Apple trolling on the latest Macbook or whatever for example filling the front page.

  20. That's some serious scope creep... by syousef · · Score: 5, Insightful

    In general it does depend on what application you re-use. If you reuse a poor piece of software you're building your product on shaky ground.

    Now I actually don't like Hibernate and Spring all that much and I use them regularly. Replacing a whole bunch of boiler plate code with a whole bunch of boiler plate XML doesn't actually make your app less error prone. Introducing AOP makes it easy to code cross cutting concerns but can make it hard to debug and understand code as it becomes harder to trace (and instead of a pure stack, you again have to look at XML configuration). Then there's the massive overhead. I'm afraid their popularity is due to software as religion pushed by a culture of marketing, rather than being based soley on techical merit. Hell a few years ago EJB was the word according to Bob, and we all saw how well that went. Try finding a new project actively deploying EJB today.

    That said, I've run into the limitations of those products, especially hibernate, and if your scope has crept enough that they were looking like a good solution, but aren't anymore, you need to address the scope creep first. Some creep is expected, and accomodating the business is always a good idea if you can manage it, but people go too far and forget that sufficient scope creep can and will make your project fail. You need to start by talking to the business and ensuring they have an understanding that the more redesign they do after the initial planning the greater the cost and risk. One other thing to watch out for. Make sure you evaluate whether each request is technically possible in the first place, and whether it is practical to attempt what has been asked with the resources you have. (I've often seen business people make requests without understanding the technical effort required. eg. request a change requiring a full blown compiler be written when the component was suppose to be a very simple parser and was scheduled to take 2 weeks to code. That's not entirely their fault. YOU are the technical staff and need to help them understand what is involved in fulfilling their request.).

    Once you've addressed the scope creep, look at your application again and re-evaluate the tools. It may be possible to divide the project in such a way that you retain Hibernate and Spring for one part (and let's face it they're the defacto industry standard and are going to be the easiest to support in the short to medium term. Long term is harder to predict, but the less popular an approach is the harder it will be to find someone appropriate to maintain your app). The other part you can do with raw JDBC or another tool. (eg. you might find it's the reporting that Hibernate isn't dealing with adequately, so move to JDBC or a reporting framework that takes RAW SQL queries).

    --
    These posts express my own personal views, not those of my employer
    1. Re:That's some serious scope creep... by eille-la · · Score: 1

      I'd like to know what you dislike of Hibernate. I am in the process of learning the whole library and find it quite useful right now. I guess you might be an experienced developer and should be able to provide examples and details to back your opinion. Not that I am an hibernate zealot or anything, I am just curious about the alternative or better ways to develop project with something else then hibernate when that kind of tool is needed.

      Pierre

    2. Re:That's some serious scope creep... by Anonymous Coward · · Score: 0

      Now I actually don't like Hibernate and Spring all that much and I use them regularly. Replacing a whole bunch of boiler plate code with a whole bunch of boiler plate XML doesn't actually make your app less error prone.

      Right on brotha.

      Try finding a new project actively deploying EJB today.

      EJB2's sucked. EJB3's are quite nice. Give them a try, you might be surprised. Very little reliance on XML, heavy reliance on annotations (so you never see the boilerplate code). Allows you to plug in your own persistence framework and code to a standard API for it (e.g. when you realize hibernate is buggy and want to replace it with Toplink).

    3. Re:That's some serious scope creep... by syousef · · Score: 2, Insightful

      I'd like to know what you dislike of Hibernate.

      Where to start...

      If you're writing something simple with very straight forward relationships and are able to define your database yourself up front it's not too bad. You lose some performance in caching, but also gain some in that hibernate does well using indexes to generate sane queries.

      The idea that you don't have to hand code is only partly true. The low level database calls are indeed done for you but your mapping isn't - some of it is just moved away from Java and into XML (You still have to code the object class...some of that can be done for you if you use the right tools but the tools keep breaking and/or being re-written so a lot of people end up doing it by hand. One of the stupidest bugs I ever introduced to code was mis-capitalizing the instance variable in an accessor for one of the fields that mapped to the DB. As a result, hibernate would null that field and save to the database even though save was not explicitly called - the app ended up clearing out reference data in the database!). So my experience with hibernate as a tool to remove errors hasn't been all positive. My experience with the tools hasn't been all positive.

      Next there's HQL. What an abomination. Not every piece of SQL you can write will map to legal HQL. DB specific stuff, while not a good thing to use in the first place, just doesn't work in some cases (or at least didn't in Hibernate 2. That may have been fixed). You end up falling back on JDBC for stuff that needs that. I even vaguely recall problems with certain standard SQL...certain group by clauses or sub-clauses didn't work.

      Next take a look at the way more complex mappings work. Some of the options in the XML mapping files are not intuitive at all. In fact you have to spend considerable time to understand what they are doing, and even then complete understanding only comes when something breaks. It can be very difficult to tune the mappings so that they work well for all the various scenarios in your application, so you have to make compromises.

      Finally, I've worked on proprietary data access frameworks (mostly in Smalltalk, not Java) and they can be quite a burden to maintain, but I see an equal amount of pain trying to keep up with the latest Hibernate version and work out whether you want to do it their way or use Spring to wrap the data access.

      Talk to a Hibernate fan and they'll come up with something to counter each of the above (as that is the nature of the fan) but as far as I'm concerned Hibernate is not the magical wonderful error free data access framework it's made out to be. There's no such animal.

      --
      These posts express my own personal views, not those of my employer
    4. Re:That's some serious scope creep... by abes · · Score: 2, Insightful

      Hibernate is a pretty good product. It has nice features that allows you to abstract tables into OOP representation. Joins can be specified optionally on column values. And while the XML can be hard to parse, it now allows for annotations to be done in the Java code itself.

      That said, when Hibernate fails, it can often be hard to figure out why. It's error messages can be hard to parse, and difficult to trace where it originates. Also, I've definitely come across places where hacks had to be implemented into object relationships in order to get cascades to work properly.

      If Hibernate has any really big issues, is that it probably promises to do more than it actually can. But with that said, if you need Hibernate to do things outside of its general scope, you probably don't want to use SQL in the first place.

      Instead of placing all your requirements on a single product, it might be worth figuring out how each dataset can be stored most optimally. If you're doing a lot of key-value storage, you can store large datasets with MemCached, and write to disk.

      If you need to do relational queries on some of that data, you can create a SQL representation that points to the data you want. Also SleepyCat DB might be worth checking out.

      Apple has jumped in on the fun in this regard, by making key-value bindings a central part of Cocoa. Again, there are no silver bullets -- use the best tool for the job as always..

    5. Re:That's some serious scope creep... by timewasting · · Score: 2, Insightful

      Wow, I almost totally agree. I hate spring for all the stupid interfaces that usually get created and then replacing simple compile-time problems with hunting through a zillion XML files to try to find what the root cause of a cryptic runtime exception is. I'm also a big fan of EJB3 and it's implementations up the Kodo/BEA/Oracle JDO food chain.

    6. Re:That's some serious scope creep... by julesh · · Score: 1

      Hibernate is a pretty good product. It has nice features that allows you to abstract tables into OOP representation.

      The problem with hibernate is that too many people use it when they want something with features that allow you to abstract objects into table representations. There are much simpler ways of doing that, without the complications of a library designed to work with arbitrary tables.

    7. Re:That's some serious scope creep... by Anonymous Coward · · Score: 0

      That's right, if EJB going into oblivion have taught any lesson, it is that Hibernate is the next in the line. Why? Because both are essentially Object Databases in the middleware and we all well know where Object Databases are now.

  21. Better Requirements Gathering by twistedfuck · · Score: 1

    Sounds to me like you need to improve your requirements gathering. If you had gathered all the possible requirements, and tried to predict a few also, then you could have likely selected a framework to match your current project's scope, and the scope creep also.

    1. Re:Better Requirements Gathering by syousef · · Score: 1

      Sounds to me like you need to improve your requirements gathering. If you had gathered all the possible requirements, and tried to predict a few also, then you could have likely selected a framework to match your current project's scope, and the scope creep also.

      I'm seeing a lot of statements like this but...

      1) The business people tend to change their mind and expect technical staff to cope. It's hard to gather requirements if even the business doesn't understand what it wants to do. (Your job becomes trying to help them understand and letting them know how costly late changes to scope are, but that's assuming they're willing to listen).

      2) Business needs change. Sometimes the regulatory rules do too.

      --
      These posts express my own personal views, not those of my employer
    2. Re:Better Requirements Gathering by Todd+Knarr · · Score: 3, Insightful

      The problem is that the standard response from the business people, when I try to anticipate future requirements, is "But we're not asking for that. Can't you just do what we asked instead of adding all this extra stuff that's taking too much time to do?". Part of it seems to be that business wants and is given the authority to add to and change the requirements, but never been required to take responsibility for the consequences of those additions and changes.

    3. Re:Better Requirements Gathering by Hairy+Heron · · Score: 1

      Wow you must work in the only software company on earth where every single requirement can be had up front before any coding is done. Those of us in the real world, though, realize that such a thing is never possible.

    4. Re:Better Requirements Gathering by Anonymous Coward · · Score: 0

      Sounds like your team is missing an effective requirements change management process.

      Typically such a process involves a business person filling in a form requesting a change to the requirements. The technical guys and pm then assess the impact to both the budget and the architecture.

      If the business accept the increased costs then it is accepted and can be applied.

    5. Re:Better Requirements Gathering by ClosedSource · · Score: 1

      It's not really about process but about power. Management reserves the right to change requirements, ignore agreed upon limitations, expect quality code without providing time for testing etc.

      Strangely enough, sometimes these behaviors are appropriate. You may be working at a start-up that just lost some of its funding and it's a do or die situation.

    6. Re:Better Requirements Gathering by Todd+Knarr · · Score: 1

      And when the form exists, what you end up getting back when you say "OK, that change is going to add 3 weeks to the schedule." is "That's not acceptable.". And no process in the world will help with that.

  22. puzzled... by BillAtHRST · · Score: 1

    Just what is it that makes ORM a non-starter for this project?

  23. Hibernate doesn't completely suck. by FatherOfONe · · Score: 1

    I have now done a few projects now with Hibernate, JSF Netbeans 5.x-6.1 and can feel your pain. I ran across some HUGE bugs and issues that if I would have just done it with JDBC it would never have shown up. Having said all that once I got through the bugs and did some workarounds (Sun support sucks), it is a lot better. I still wouldn't use Hibernate JSF and Netbeans for everything but it doesn't totally suck.

    Here are some high level things that might help.
    1. If you have a relationship between classes and it only needs to be a one way association do it. Avoid bi-directional associations at all cost.
    2. Hibernate can use pure sql and it's own variant of SQL. Use them when you have to. We try hard to avoid every putting SQL in to our code but there are times when we had to do it.
    3. Hibernate wasn't made for 40k objects in memory at one time. If you need that then it is possible but you will have to change some caching options.
    4. Lazy instantiation. In theory it sounds great, in practice it doesn't. This may start a holy war on Slashdot, but I had to avoid this.
    5. Working with Arrays of associated classes and having to make changes to them.

    --
    The more I learn about science, the more my faith in God increases.
    1. Re:Hibernate doesn't completely suck. by syousef · · Score: 1

      I have now done a few projects now with Hibernate, JSF Netbeans 5.x-6.1 and can feel your pain.

      Mainly talking about Hibernate here. It's always good to hear you're not the only one. When I was learning this stuff (having come from different languages and frameworks) I always felt like I was somehow "not getting it" because things that should've worked easily broke or couldn't be done at all with the framework. As I've become more experienced and my experience has grown, I've realized that these frameworks really only work close to as well as advertised if you use them within the narrow context they've been built for.

      --
      These posts express my own personal views, not those of my employer
  24. Mmmmmmmmmm by Anrego · · Score: 1

    I tend to turn to the math when this problem presents itself.

    I`m a programmer.. not a project manager.. but I can still usually put some kind of approximate number on the time it's going to take me to write from scratch (or re-write) vs. adapt/hack a lib into what I need.

    Factor in deadlines, maintainability issues, support issues, sanity, the phase of the moon, the flacid length of my firehose at room temperature .. and I have my decision.

    As a side note, I don`t know what specific problems your having.. but I think if JDBC has become preferable over Hibernate.. you're doing it very wrong ;p

  25. Yup, you've hit the nail on the head by telchine · · Score: 1

    This is what I come up against. You're fine with off the shelf stuff as long as the requirements match (and continue to match) the design of the product you're working with. The more it differs, the more you find you have to spend time learning the ins and outs of the product you're working with. This can get to the point where sometimes it'd be quicker to write it from scratch yourself than learn the product inside out.

    The balance I try and meet, is to choose lots of smaller off the shelf components rather than one large monstrosity. If the requirements change, the n often you only need to swap out one component or two and continue with relatively little disruption.

    The real solution is to make sure the requirements are right from the start. If you succeed in doing this, tell me how!

  26. Quick vs Long by bgibby9 · · Score: 1

    Basically it comes down to this. If the project started out as a "let's get something going and work from there" project and has now become something of a "this thing works, let's extend it's functionality" then you've got to make a choice.

    Either take the concept and build it correctly (either by writing from scratch or extending the classes that you have) or continue to hack it.

    I feel that taking a prototype and making it a production quality application needs to have the time spent doing it right! Prototypes fall over, it's their nature, but you don't want the same behaviour from your production apps!

    --
    http://www.gibby.net.au
  27. Reuse by Anonymous Coward · · Score: 0

    Reuse is only useful *if* you control the libraries that you are reusing. As new requirements come along that exceed the abilities of the libraries you are using, you need to modify those libraries and increase their capacity/use - this will allow for better future reuse.

    When those libraries aren't open source, or when modifying them will create issues for other projects, reuse simply leads to stagnation.

  28. Reuse, but not for reuse's sake by VGR · · Score: 1

    Code reuse is a nice goal, but it's hardly the core definition of good software engineering. Code reuse is a benefit that arises from good design; code reuse as a goal unto itself is little more than wasted effort driven by cargo-cult misconceptions.

    The thing most people overlook is that for code to be reusable, it must first be ... usable. Code has to be well defined, well designed and well documented in order to be usable and thus reusable. Sure, you can reuse it even if it fails those qualifications, but it will mean more work than not reusing it.

    --
    The Internet is full. Go away.
    1. Re:Reuse, but not for reuse's sake by jomegat · · Score: 1
      Code reuse is the one practice that can impact the cost of a project more than any other thing. But it can impact it in either direction, depending on the code you reuse.

      Management has a tendency to ask engineers to reuse the wrong code almost every time. Code that has been badly designed and/or badly implemented is code that comes up in management meetings. Every week. For months. They start tracking it, and finally, someone beats the code into submission, and they add up the cost. "Wow. $150 thousand!"

      The next time a project comes up and management can possibly imagine that their $150,000 "investment" might get leveraged, they push the engineers to reuse that code. "It must be good! It cost us $150,000 to develop it!" The reality is that this code should have been taken out behind the shed and shot. When it gets reused, even more bugs will be found, and the cost of the project will go up.

      On the flip side is beautifully designed and implemented code. It works almost immediately, and without wringing of hands and gnashing of teeth. It therefore never sees the light of day at a management meeting. It is beneath their radar. They will never suggest that it be reused, because they know nothing about it. That's the code you want to reuse.

      --

      In theory, practice and theory are the same. In practice, they're not.

  29. Yeah! by gbutler69 · · Score: 5, Funny

    I always write my own bootloader, device drivers, operating system, assembler, compiler, C-interface library, graphics libraries, hardware abstraction layers, collections, and algorithms first. Then I just write a thin layer on top of that to implement the desired functionality. Easy, peasy, japa-neasy!

    In my spare time, I grow my own grain, raise my own cattle, remove my own spleen and even generate my own electricity my peddling my home-made bicycle vigorously!

    --
    Over-the-top Response Guy! Giving "Over-the-Top Responses" since 1970.
    1. Re:Yeah! by Anonymous Coward · · Score: 2, Funny

      I always write my own bootloader, device drivers, operating system, assembler, compiler, C-interface library, graphics libraries, hardware abstraction layers, collections, and algorithms first.

      Who are you, Linus?

    2. Re:Yeah! by Thiez · · Score: 1

      Mom?

    3. Re:Yeah! by mdielmann · · Score: 1

      ...generate my own electricity my peddling my home-made bicycle vigorously!

      Better put a grammar-checker on your project list.

      --
      Sure I'm paranoid, but am I paranoid enough?
    4. Re:Yeah! by Viceroy+Potatohead · · Score: 1

      Exactly!

      You're probably also at the point where all you see is blonde, brunette, redhead...

      After all these years of looking at machine code and thinking "That's an a$$hole place for a jmp instruction" I'm very happy to finally access the pornucopia with my custom-built trinary system (zeros, ones, and ironing boards), using little more than a network protocol layer based on the works of Groucho Marx.

      Fscking amateurs, that's what I call the rest of them.

    5. Re:Yeah! by Anonymous Coward · · Score: 0

      Bit of a strawman though.

      There is the Law of Leaky Abstractions and in practice (in my industry) this means it is almost always better to write from scratch. Yes, really. Code re-use has always caused more problems than it solves (except for the age-old method of copy-and-paste).

      However, the C language and everything below it (including hardware) provides a non-leaky abstraction so it's fine to base stuff on that.

    6. Re:Yeah! by Hognoxious · · Score: 2, Funny

      peddling my home-made bicycle vigorously!

      Nobody's buying that.

      --
      Confucius say, "Find worm in apple - bad. Find half a worm - worse."
    7. Re:Yeah! by Anonymous Coward · · Score: 0

      I actually find it easier to design my own custom chip and circuits first, optimized for the requirements of the application. Floating-point arithmetic? YAGNI. I usually specify a BCD sub-processor.

      The only "problem" if you want to call it that, is that it takes a long time to get these projects funded. But heck, if they want crap. . .

  30. Use JPA by gbutler69 · · Score: 1

    Waaaaaay better!

    --
    Over-the-top Response Guy! Giving "Over-the-Top Responses" since 1970.
    1. Re:Use JPA by kbrasee · · Score: 1

      I'm a fan of JPA after using it on a decent-sized project (Spring MVC web app using Hibernate's JPA implementation). From what I've seen of original Hibernate config this does look a little simpler, primarily due to the annotations. However, I did run into a few JPA and JPA+Spring quirks that took up quite a bit of my time and would never have been an issue if I stuck to straight JDBC.

      Would it have been quicker if I went with JDBC instead of JPA? Maybe. But now that I've got an idea of how to work through the minor issues, I'm pretty sure it'll save me some time on my next project.

    2. Re:Use JPA by Anonymous Coward · · Score: 0

      LOL.

  31. start over by Anonymous Coward · · Score: 0

    I know nothing of the scripting languages you are using. What I do know is requirements almost always creep. It is hard to stop creep as the urge is there to please the customer. If you deliver something they wanted a year ago it is unlikely the thing they want today, that's the nature of custom built items. Requirements will likely continue creeping unless you are almost done and then the customer is itching to get their hands on the product before you are comfortable you have thoroughly tested it.

    If there is a large ways to go on the project, restart. You seem more comfortable in the scalability of the other language so use that.

    Also, a lot of the comments I have read seem to address what he should have done. I agree, but unfortunately, that's water under the bridge.

  32. ORM != Reusable code by Foofoobar · · Score: 1

    ORM has it's own problems for database run applications. It adds alot of overhead to the amount of data you have to load when you could be customizing your queries to each method that has to call the database and just have the class instantiate a DB object instead. Is this a little more work? Yes. Is this more scalable? Definitely. Is this 'messier'? Depends. I abstract the sql into a separate database layer so it isn't even included in the functions; that way the DBA can mess with the database queries as much as he wants (as long as he is communicating his changes to the developers) and the developers don't have to see all those queries in their code.

    ORM is a solution only if you are fanatic about turning EVERYTHING into an object but a true engineer knows that one tool does not fit all paradigms. And ORM is such a case where objects tend to fall short; good in the short run but the more you try to scale your application up, the more ORM becomes a problem and you end up falling back on hand coding your queries.

    --
    This is my sig. There are many like it but this one is mine.
    1. Re:ORM != Reusable code by Jherico · · Score: 1

      ORM preserves relationships between tables much more effectively than pure SQL backended DAO's. The hierarchy navigation mechanism is much more natural. For instance its a lot easier to make a query for 'track.album.artist.image.url' than to do the corresponding SQL joins, and if you were to write those SQL joins, that SQL would likely be useful nowhere else. What's more, its likely to break on the smallest schema change. I use hibernate extensively and while I had many reservations about it at first, virtually every problem I've encountered was solved by gaining a deeper understanding of the framework and its query language.

      --

      Jherico

      What can the average user can do to ensure his security? "Nothing, you're screwed"

    2. Re:ORM != Reusable code by mini+me · · Score: 1

      Then again, a true engineer would probably recognize that SQL is often the wrong tool for the job and use a database that was designed to scale (vertically) instead.

    3. Re:ORM != Reusable code by Foofoobar · · Score: 1

      And while you preserve the relationship, you expose methods to data that they shouldn't have access to or you load excessive data; if you are wishing your methods to only have access to limited data sets to preserve data security or to limit data being loaded, ORM is not your answer. The database preserves your relationships, why do you need to preserve the relationships between objects containing that data??

      --
      This is my sig. There are many like it but this one is mine.
    4. Re:ORM != Reusable code by Jherico · · Score: 1

      The database preserves your relationships, why do you need to preserve the relationships between objects containing that data??

      The database preserves the relationships and enforces them. It does not make them easy to use or understand as anyone who's had to work with a schema involving more than a handful of tables and dozens if not hundreds of foreign key relationships will understand. Indeed you don't have to know anything about SQL at all in order to take advantage of an ORM mapping (though it helps). People who think that SQL is the best solution to interacting with a DB are a priori DB people. But there are a lot more people that have to work with information out of a DB than just DB people.

      I work on a huge content management system system for a major media company. The fact that we have an ORM mapping to this system gives us several advantages. First off, its about 10 times easier to maintain and extend than the previous SQL only based system. Second, its a library that we can build on easily. We have dozens of apps based on this library from bulk data import, to an editing and viewing web application to bulk indexing of data for internal search engines. All these things would (and in some cases did) require extensive custom SQL code for each application. Finally, the ORM library is easy to hand out to people for them to build upon without the customer requiring a detailed understanding of the schema. In 4 years of working with this ORM model, the ONLY time I've had to resort to SQL was to get around a design flaw in the schema that predates the use of ORM.

      Your commentary about security is nonsense. The data model does not equal the access control model and conflating them in order to demonstrate ORM is somehow flawed or dangerous is either disingenuous or ill-informed. If you're actually trying to stuff them into a single entity then its small wonder you're having lots of problems.

      --

      Jherico

      What can the average user can do to ensure his security? "Nothing, you're screwed"

    5. Re:ORM != Reusable code by Foofoobar · · Score: 1

      Thats a very good argument for non-database people to use databases. But not a very good argument for using ORM for scalable projects. Because if you need a project to scale, you will NEED to understand databases and have custom built queries and query caching in place. Building these into a separate database layer easily makes it so the DBA can make these changes separate from the application.

      While ORM may simplify in some respects, it also overcomplicates the process and makes queries take longer or return too much data thus increasing the load on a database. A truly database driven application that is intended to scale to any level beyond an entry level market would not use ORM. I use OOP in just about everything I do but the OOP model is overkill when applied to the database model which is why it drastically slows the process in comparison to a separate database layer in your application.

      --
      This is my sig. There are many like it but this one is mine.
    6. Re:ORM != Reusable code by Jherico · · Score: 1

      Because if you need a project to scale, you will NEED to understand databases and have custom built queries and query caching in place.

      That's simply not true. My customers tend to be editorial types who want a simple API to access the data AND they want it to scale but they don't know jack squat about DBs and honestly they shouldn't have to.

      Building these into a separate database layer easily makes it so the DBA can make these changes separate from the application.

      Which is exactly what we do with our ORM mapping.

      While ORM may simplify in some respects, it also overcomplicates the process and makes queries take longer or return too much data thus increasing the load on a database

      Again, this isn't true. You can needlessly increase the load on a DB with bad ORM, but you can do exactly the same thing with bad SQL. You sound like someone arguing that assembly will always be better than high level languages or that C will always be better than Java because of better use of resources (I used to make this same argument myself). It turns out that while technically you can always produce a faster more efficient solution in ASM/SQL/C, in practice, once the competing technology has matured the performance differences are negligible. Further, the gains you achieve in maintainability tend to outweigh the losses in computing resources. Sure, oracle instances are expensive but they're nothing compared to engineering man-hours.

      A truly database driven application that is intended to scale to any level beyond an entry level market would not use ORM.

      I've seen an ORM based solution for creating search indexes of basically the entire music catalog of all the major labels in the united states with significant connectivity between the records. If you simply believe it can't be done, then there's nothing I can do to force you to believe otherwise. But I've seen it done, so I believe.

      ... OOP model is overkill ...

      In my experience anyone who says this or anything like it is focused too much on execution and not enough on maintainability. OOP is overkill for toy problems and that's about it.

      --

      Jherico

      What can the average user can do to ensure his security? "Nothing, you're screwed"

    7. Re:ORM != Reusable code by Foofoobar · · Score: 1

      My customers tend to be editorial types who want a simple API to access the data AND they want it to scale but they don't know jack squat about DBs and honestly they shouldn't have to.

      You're customers want a database driven application but their development staff doesn't want to have to know anything about databases? That my friend is a recipe for disaster. If you honestly believe that the maintainer of a database driven app doesn't need to know anything about databases, you are very very naive.

      ...Which is exactly what we do with our ORM mapping.

      with overkill. Loading too much data, improper query caching, allowing methods access to data that they probaby should not have access to. Your query is custom built for the method to increase speed, limit datasets and secure data for the method calling it. ORM bypasses all of this in one way or another adding overhead, allowing access to data when it should not be allowed to the function and other bad practices as well as the overhead of have to access a relationship to access the relationship; dept of redundancy dept. calling.

      I've seen an ORM based solution for creating search indexes of basically the entire music catalog of all the major labels in the united states

      Yawn... try a 10 terabyte searchable customer database actively being updated with hundreds of customer records per second for a telecom. And that doesn't even count the reads!!! And thats JUST the customer database. When I worked at Amazon, puttin book data into the database is just as similar as that music database. It's not too hard to make that searchabl with orm as the datasets are HIGHLY repeatable. But when you are talking about nonrepeating datasets... ORM cannot scale.

      --
      This is my sig. There are many like it but this one is mine.
  33. The right lesson is... by dethkultur · · Score: 1

    "Now, I used to be told that good programmers write code and great programmers reuse code." is sort of right.... the correct lesson is: "Good programmers borrow, great programmers steal." Same lesson applies to marketers. And to poets (Robert Frost said it first, speaking about poets.) Oh, and to politicians, esp if your name is Joe Biden.

  34. Learn how to use the tools... by Anonymous Coward · · Score: 0

    The Spring/Hibernate combination is very flexible. I find it hard to imagine you've come up with something these guys haven't thought of. If you're using the latest versions of these tools you should not have to deal with XML hell.

  35. Ecellent programmers by geekoid · · Score: 1

    Understand who to mitigate creep, get sign offs on changes Including time changes and architecture changes.

    Creep is fine, just be sure someone signs off on the details.

    If they won't, don't change your work.

    --
    The Kruger Dunning explains most post on /. http://en.wikipedia.org/wiki/Dunning%E2%80%93Kruger_effect
    1. Re:Ecellent programmers by geekoid · · Score: 1

      And no, they don't need to spell~

      --
      The Kruger Dunning explains most post on /. http://en.wikipedia.org/wiki/Dunning%E2%80%93Kruger_effect
  36. iBatis Rules by Anonymous Coward · · Score: 0

    Check it out: http://ibatis.apache.org/

  37. When in doubt, roll your own. by parabyte · · Score: 1

    The more you build on top of something, the more solid the base should be.

    If your own stuff is just a few thousand LOC, it does not matter that much if you are locked into a particular framework. You can still do it again with another framwork.

    However, if you investment is a major one, you better roll your own or use something rock solid, that even has different implementation with a similiar API or functionality, like a database or script interpreter.

    And when in doubt, roll your own or built an abstraction layer.

    p.

    --
    Without order, nothing can exist. Without chaos, nothing can be created.
  38. The new requests coming in involve capabilities by dindi · · Score: 1

    "The new requests coming in involve capabilities "

    Any project should start with a complete specification of the final product. Yes I know, I also have IT and non-IT partners who DO NOT/CAN NOT/WILL NOT understand this, and then technically pay for every rewrite one way or the other.

    Well, just my 2c. When you require at least an outline of WTF they WANT, this happens to you less and less. When you explain it to them for the 50th time, that it will take SERIOUSLY LONGER to modify something, than plan for it in time, they will also start to understand. Slowly though, as they are IDIOTS!!! Did you find it out yet? They are MORONS!

    Sorry, don't know what to tell you, I usually write and reuse my own database classes, do not know hibernate and only use ODBC when I really have to (e.g. modifying some ASP crap that already uses it, or SQL 2005 with PHP is easy with it). Just use PDO or mysql_ or mssql_.

    1. Re:The new requests coming in involve capabilities by chromatic · · Score: 5, Funny

      Any project should start with a complete specification of the final product.

      Slowly though, as they are IDIOTS!!! Did you find it out yet? They are MORONS!

      You're the liason between programmers and customers, because you're good with people. Did I get it right?

    2. Re:The new requests coming in involve capabilities by shutdown+-p+now · · Score: 1

      You're the liason between programmers and customers, because you're good with people.

      It doesn't look like he is one now, but he certainly used to be, judging by the attitude.

    3. Re:The new requests coming in involve capabilities by dindi · · Score: 1

      No, I am good with people and bad with idiots. Even though that is the truth, I can handle people quite well, and make them think they are all right......

      I think it just needs enough explaining, and charging them till they understand.

      And I am a programmer, but I worked both as a manager, programmer, tech support and product manager, so I clearly see where the problems occur in the chain....

  39. Do it from scratch until you hit something hard by togofspookware · · Score: 1

    I got quite a taste of a few Java frameworks from my last job (Hibernate and Tapestry, to be precise, and given my experience, I'm inclined to agree with the 'hibernatesucks' tag. If you had mentioned Tapestry I would have agreed even more with a 'tapestrysucks' tag, because Tapestry does suck, hardcore. Hibernate I can at least see being semi-useful in some situations).

    My view is this: If you're making a simple project, implement it in a simple way. You've got to expect new requirements to come in, so don't go choosing *any* sort of 'framework' right off the bat.

    <tangent> Unfortunately you do have to choose a programming language -- I'm not too thrilled with any of the offerings right now. PHP is hosted everywhere, but in 3 different incompatible versions. I use Ruby, but in order to ensure it works on whatever web host, you've got to use it with CGI, so hope your site doesn't get a lot of traffic! If you have a host that lets you run Java servlets and whatnot (despite my old job I'm not especially familiar with how Java applications get hosted), then I'd say Java's a good choice - not my favorite language, but it's fast and stable. </tangent>

    Only when your program (/web site) actually needs to do complex things that would take a lot of time to implement (graphics libraries, hardware drivers, complete xml parsers come to mind) should you start bringing in external libraries. And note that I said "libraries", not "frameworks". 'Frameworks', in my view, provide 2 things:

    • A standard set of libraries
    • A standard way to structure your code

    If you can use those libraries that you need without a framework, it's going to be in your best interest not to include the extra frameworky stuff in your project that you don't need (get to the why in a minute). Importing a standard way to structure your code from a widely-used framework can be useful if you're working on a project with several other developers who would otherwise either argue about what made-up in-house standard to use or follow no standards at all, but if you're doing this thing by yourself, you can probably fulfill the needs of your project more simply by doing it yourself.

    Even when you're importing functionality that will be controlled by your program (a library), and not the other way around (a framework), I would encourage you to try to implement it yourself, first. You know the specific needs of this project better than the people who wrote any libraries, so you may be in many cases be able to write something vastly simpler that gets the same job done in a way that makes more sense to you (not to mention that many libraries are simply crap, such as the ruby-git wrapper I recently downloaded before writing my own version that bothered to escape arguments to shell commands). If you do this enough times you will find that things you thought were difficult to implement are not so bad, and will wonder why so many people think they need a library.

    To summarize, I agree with the guy who said "It's knowing when". Also, for the most part, with Chuck Moore, even though I'm not a Forth programmer ;)

    --
    Duct tape, XML, democracy: Not doing the job? Use more.
  40. boring by xdroop · · Score: 1

    Coder digs hole, asks for comments on different shovels and other holes; film at eleven.

    --
    you should read everything on the internet as if it had "but I'm probably talking out of my ass" appended to it.
  41. Always code it yourself. God will love you. by Anonymous Coward · · Score: 2, Funny

    Unless your employer pays you to reuse code, you should always code it yourself.

    Look, the man is sticking it to you. You know it. I know it.

    Let's stick it to da man. Code your BIOS, your OS, your framework, your driver, and your app. It's fun. It's profitable. Your doges will love you.
    Your wife will love you. In Alabama, your sister will love you.

    Reusing code is for wimps.

    When is the last time your review mentioned code reuse?

    Come on. We are paid to create things!

    God said, be fruitful and multiply. He didn't say be fruitless and reuse other peoples kids.

    So obey God and do His will. Create something old.

  42. Reuse good code as much as possible by TheLink · · Score: 5, Insightful

    Actually, the trick is knowing that you _aren't_ a great programmer (honestly what are the odds that you are a great programmer?), and thus choosing to reuse code from better (and hopefully great) programmers.

    If you wish to delude yourself, you can believe that you are a great but lazy programmer and thus choose to reuse code from other great (and more hardworking) programmers.

    Stuff like Perl + CPAN is good because of all that code you don't have to write. The less code you write, the fewer bugs you make.

    More importantly the less code you write, the less code OTHER people have to figure out. If you use popular libraries/modules whenever possible, other people can just go "Ah, the standard wheel", instead of going "He calls it a wheel but is it really a wheel? Better check, the bug might be there". Or they might even go "Ah yes, it's probably that bug in the standard wheel, when are they going to get it fixed already, meanwhile we'll do the recommended workaround".

    You can also reuse "code" in other ways. For example - using a popular RDMBS is one way of reusing code. With a good database you don't have to reinvent transactions, row level locking and all that. Lots of smart people have done all that work already. And you can use the DB as a common "interface" for other programs (also written by other people).

    A lot of the languages the CS academics heap praises on are powerful for the code you have to write, not the code you don't have to write. Yes it's probably a catch-22 thing, but when it comes to "real world", I'd rather pick the language where I don't have to write so much stuff.

    Prefab may be uglier, but it beats spending 10 years carving that perfect sculpture all by yourself, only to have the customer say "erm I want a sculpture of my wife not my ex-wife...".

    (Note I am not a great programmer, so feel free to ignore me).

    --
  43. typical, so typical by Ancient_Hacker · · Score: 1

    this is the usual hobson's choice. you load up some framework and WOW, 70% of the work is done for you! Whopee! Then the boss wants the buttons to update differently and you find it really hard to do that within the framework, but you manage by adding kludges in 73 places. Then you realize you really need a way to rollback or failover or fooswank and of course it's hard to impossible to wedge that into the framework. And then version 2 of the framework comes out and all your kludges you have to reimplement.

    in other words the framework makes the first 70% easy, the next 20% difficult or slow, and the critically needed last 10 percent very difficult to impossible.

    I've seen this time after time, with Hypercard, PowerBuilder, Notes, etc, etc, etc...

    1. Re:typical, so typical by /dev/trash · · Score: 1

      Drupal is notorious for this.

  44. I don't get Hibernate et al. by zigamorph · · Score: 1

    I prefer to code JDBC directly. Then I at least know what it is doing and can track down and resolve bottle-necks. Plus: there's less xml. For simple, low load applications it's probably ok but even then I find that it is better to get your hands dirty. You're going to need the experience when you tackle a not so simple application.

  45. Reuse where possible by CharlesK80 · · Score: 1

    The benefits of reuse is that you have less code to maintain and costs fall, someone else does the testing and bug fixing of that code so you don't have to. The best thing you can do with a line of code is delete it I say. As long as the code being reused is from a good project (i.e. open source, active, mature, etc), always reuse.

  46. pst. by Anonymous Coward · · Score: 0

    God damn you software engineers.

  47. Doing it from scratch has other dangers... by TrixX · · Score: 1

    Sometimes you feel that working from scratch "would have been better". But you might be missing lot of details you have taken for granted or even never knew they were there, and you will have to face them.

    There is a great article from Joel related to this... he actually speaks about saying "this sucks, let's rewrite it" so it's not exactly the same, but the points have a lot in common with your case. I recommend you to take a look at it.

  48. Document! by Mongoose+Disciple · · Score: 1

    Here's a point I haven't seen raised yet: whatever you decide, document the hell out of the why in your code.

    Maybe you do some analysis and figure out that Hibernate doesn't work for what you have in mind. You go your own way. If the why for that isn't very explicit in your code, the developer who has to maintain your code two years later will likely look at it and think, "The person who wrote this was a dumbass. They didn't know enough to use Hibernate for this!" Or they didn't understand Hibernate well enough to know how to do it the 'right' way. (And even if you do your research, it's possible this is true.) If you make clear notes of why you made the decisions they did, the person who has to maintain your code down the line will be considerably less inclined to want to murder you.

    This is especially important if that person is a psychopath, or you, or both.

  49. reuse good code and rewrite bad code! by neonsignal · · Score: 1

    Seriously though, new requirements that come in after a project is written are often hard to fit into the framework.

    That doesn't necessarily mean always writing from scratch just so modifications can be made more easily. Quite often the advantages of a well written library (good coverage of a domain, a worked over design, tested by multiple users, and quick to incorporate) outweigh the ability to precisely meet each new requirement.

    No point in perfectly meeting requirements if the project is never finished (conversely you could argue, no point in finishing if you can't fulfil the core functionality!).

  50. Reuse as much as possible by hierro · · Score: 0
    The less code you write, the better. Keep in mind that a given computer program should always be measured by functionality, not by SLOC. Keep in mind that every line you write implies:
    • More possible bugs
    • More testing
    • More maintenance
    • More complexity

    So my advice is reuse as much code as possible. However, as others have pointed out, check what you're basing your work on. There are a lot of shitty libraries and frameworks out there and for those cases you're better off rewriting the whole thing.

  51. When you understand the problem by shareme · · Score: 0

    When you understand the problem as in project requirements are not creeping up than re-use..otherwise new problems ot you at least, new code..

    --
    Fred Grott(aka shareme) http://mobilebytes.wordpress.com
  52. Design First Then Build... It Just Never Happens. by nick_davison · · Score: 3, Insightful

    You gain efficiency by understanding a feature set and picking the right tools to do that job.

    The problem is, most people/organizations desperately want to build something now, so they feel something's happening, then keep tweaking it all over the place until they're happy, totally changing the spec once it's underway.

    In short, they want you to do the job in order for them to then understand it - making it nigh impossible to select the right tools at the beginning.

    Most of the really great, really efficient systems are built by someone who had a firm idea, figured out all the aspects, then got on and built just that. Or they played with ideas, building multiple prototypes that likely weren't very efficient, then went back and rebuilt it with what they'd then learned.

    Most systems aren't like that. They're designed by committee who won't think through most issues until they see a working version. They essentially force prototyping on you - yet consider what you're building the final system and won't pay for you to do a final rebuild. As a result, they're bloated and suck.

    Welcome to the real life of a programmer. Yes, code re-use is something great programmers do. But only if they have great designers who really think everything through first. If you ever find such a mythical beast, let me know and I'll be clamoring to work there too.

  53. Re:Reuse good code as much as possible by DaveAtFraud · · Score: 1

    I put it this way:

    1) You can rewrite/code from scratch and spend your time finding the stupid, trivial bugs that you will invariably code, or

    2) You can reuse someone else's well used code and spend your time finding the really nasty, non-obvious bugs that remain in their code. It should be noted that several bugs similar to but probably not exactly the same will remain to be found in your code AFTER you have found your trivial bugs.

    The choice is yours.

    Cheers,
    Dave

    --
    They that can give up essential liberty to obtain a little temporary safety deserve neither safety nor liberty.
    Ben
  54. hohum by BigBadBus · · Score: 1

    I've been involved in many software projects that either forced you to wade through pages of documentation (and we're talking WEEKS - hence loss of productivity!) or required reverse engineering of existing code (and this would take ages, as most of the team had left). If they had left API documentation, then great, no downtime. Otherwise, the quickest option is to re-write code. And the cheapest.

  55. DAO Re:code from scratch by Anonymous Coward · · Score: 0

    You can either write a straight 1:1 wrapper, or create your own API, customized to be something you're comfortable coding against. You can then replace the technology with something better, when that something better comes along, and all you have to do is change the wrapper. The other reason this is a good choice is you can provide a mock object replacement for your API and run unit tests against it without bringing up an entire web environment.

    It sounds like you're describing a DAO layer to encapsulate the use of Hibernate. Again this is a common and accepted practice.

    Having a DAO layer enabled me to get my current project up quickly (proof of concept) using Hibernate and then later move to hand written JDBC as Hibernate isn't approved in my shop (grumble, gripe).

  56. don't rewrite, extend by Jherico · · Score: 1

    In my experience, 7 times out of 10, the functionality you want IS there, you're just not well versed enough in the framework to know how to get at it. 1 time out of 10, you should be writing code, but extending the framework, not abandoning it. 1 time out of 10 you should be writing your own code separate from the library. The remaining 10% of cases are the customer asking for something retarded or overreaching the requirements into implementation.

    --

    Jherico

    What can the average user can do to ensure his security? "Nothing, you're screwed"

  57. It's news because ... by Anonymous Coward · · Score: 0

    ... it the first time a programmer confesses (s)he is married to Hibernate, ..., *that* is new!

    1. Re:It's news because ... by Anonymous Coward · · Score: 0

      News at 11: Hybernate is a man!

  58. Third option by Dan667 · · Score: 1

    Refactor when needed. That way you keep a working project and can expand it as needed (or as quickly as possible).

  59. Re:Reuse good code as much as possible by ClosedSource · · Score: 4, Insightful

    "Actually, the trick is knowing that you _aren't_ a great programmer (honestly what are the odds that you are a great programmer?), and thus choosing to reuse code from better (and hopefully great) programmers."

    This is a similiar flaw to believing that ISO certification means that a company will always create great products. Just as each product should be evaluated on its own (the UL approach), so software should be evaluated on its merits, not on the reputation of the programmer.

    There's no such thing as a "great programmer" in the sense that one individual excels in every aspect of software development. Average programmers (whatever that means) are quite capable of producing quality code. Quality code depends more on the dedication of the developers on the project than it does on programming IQ (again, whatever that means).

  60. Your first mistake... by Anonymous Coward · · Score: 0

    ... was taking a job that involved programming in Java. Your second mistake was listening to people who claim code-reuse makes for great programs.

    Great Programmers do the following:

    0.) Cultivate understanding their domain through testing of their assumptions
    1.) Write the minimal amount of code they need to do the job, and avoid complexifying the problem (in order to make it interesting)
    2.) And after testing prototypes they review, revise, and refactor, until they produce the simplest comprehendible code possible.

    A great programmer reuses code in the sense that they've learned how to solve certain specific problems, and reapply the same techniques. Successive revisions of the code need not throw everything out each rewrite, but proper refactoring by its nature requires that interfaces are not sacrosanct.

    Every time you call out to a library, a system call, or 3rd party framework, you abdicate design responsibility for that feature, accept all of the design decisions of all the developers who were involved in the development of those calls. You're stuck with the tradeoffs they decided were acceptable, as well as, all the assumptions they made about how your application would work. You also assume a minimal amount of complexity for your application in the interface code to the abstraction layer you chose.

    If you study the work of the early smalltalkers, the forth programmers, the iconic lispers, you'll see programs that are comprehendible. Entire development systems, operating systems, and applications measured in thousands of lines of code. It isn't as if computers have changed so much that these programs no longer run, or will require considerably more code to run. It is often just that the simplest design decisions we make like what language and platform we wish to support inflicts millions of design decisions upon us.

    For some real inspiration:

    http://vpri.org/fonc_wiki/index.php/Main_Page
    http://colorforth.com/cf.html
    http://sourceforge.net/projects/squeaknos/

  61. Use Neither by Anonymous Coward · · Score: 0

    Unless you like being stuck with Java!

    1. Re:Use Neither by julesh · · Score: 1

      Unless you like being stuck with Java!

      Both are available in .NET versions, if you prefer.

  62. A DAO would be an example of this... by Joce640k · · Score: 1

    DAOs are a common use of this type of programming but it can be applied to much bigger things:

    eg. A GUI layer could switch between Win32 and X11.

    A 3D graphics layer could switch between OpenGL and Direct3D. ...etc.

    Stuff like this isn't for beginner but I find this is the real key to program portability, rather then "use Java" or whatever (which will usually run into huge obstacles in long-term projects which don't fit the Java mentality).

    --
    No sig today...
    1. Re:A DAO would be an example of this... by badkarmadayaccount · · Score: 1

      Definition of irony: there is a API called Java 3D that wraps around OpenGL and DirectX for the very same purpose you described. ROFLMAO

      --
      I know tobacco is bad for you, so I smoke weed with crack.
  63. Don't just copy and paste by carlzum · · Score: 1

    One of my pet peeves is to see code copied and pasted from other projects or web sites. The naming conventions and formatting are usually inconsistent with the rest of the code and exception handling, logging, instrumentation, etc. are lacking or out of context.

    My advice is to use mature libraries whenever possible. I'd rather see my development team contribute to an open source project if we need additional features instead of writing an alternative in-house. The open source code will continue to be improved, tested, and documented, while the in-house solution requires constant investment. Plus, I can find developers familiar with popular open source projects when filling open positions.

    For your business-specific code, use "cookbooks" and design patterns instead of reusing code. If you really can't find an open source solution to a general problem, consider starting a new open source project. You'll enjoy all of the benefits I mentioned above if enough people have the same problem.

  64. Hiberate will work fine by Anonymous Coward · · Score: 0

    You can use native sql with Hibernate. I've done some crazy complex queries and it works fine. I just think you need to dig into it's documentation more.

    1. Re:Hiberate will work fine by FatherOfONe · · Score: 2, Interesting

      This isn't totally true. I can give lots of examples, but one would be to have an object that has attributes in two different databases. You might be asking why would someone want to do that?

      Lets say you are in a large company and they have many systems that make up an actual "customer", some of the info is in one system and some in another. If you are doing JDBC with a POJO then you would just build that object from the different data sources, but this becomes impossible (as far as I know) with Hibernate.

      There are other examples were you would want to use cursors and stuff, so the original poster is correct. He has a difficult decision and we can't really answer it. If he never used criteria classes and his objects are very simple AND he only has a few objects then a rewrite may be simple. However, if he has a ton of objects and used a ton of lazy loading then a rewrite will be a pain.

      I stuck with Hibernate, JSF and Netbeans (Visual Web Pack) and it doesn't suck, but I completely understand were this guy is. We have migrated to EJB3 now and it has its own set of issues (yes I know it can use a Hibernate persistent mangager).

      --
      The more I learn about science, the more my faith in God increases.
    2. Re:Hiberate will work fine by Anonymous Coward · · Score: 0

      Use toplink as your persistence manager. EJB3 will suck less.

      If you are doing JDBC with a POJO then you would just build that object from the different data sources, but this becomes impossible (as far as I know) with Hibernate.

      really? are you serious?? am I missing some subtle nuance of what you're saying.

    3. Re:Hiberate will work fine by FatherOfONe · · Score: 1

      If you are doing JDBC with a POJO then you would just build that object from the different data sources, but this becomes impossible (as far as I know) with Hibernate.

      really? are you serious?? am I missing some subtle nuance of what you're saying.

      I will try and explain a bit more (if you are reading this at all).
      You have 4 database tables that make up a customer. Table one is in MySQL on one system and table2 is in Oracle on another system and the Table3 is in Microsoft SQL Server. The fourth isn't really a table at all but a web service to some HR system. Parts of these tables make up your customer class in your new system. However, when you are done with the

      Now to clarify, I am not some Hibernate GURU, but I believe you generally create a standard pojo class and then use hibernate and an XML mapping of that one class to one data source (database). However, doing what I mentioned above with plain old Java is easy. You would build your object and when done save it to the different systems accordingly.

      If you know of a way with Hibernate to solve this problem I would love to hear it. I am by no means Gavin :-)

      --
      The more I learn about science, the more my faith in God increases.
  65. Big Bang by Anonymous Coward · · Score: 0

    If you want to write from scratch, write your own compiler and build your own system from melted glass.

    If you want to make anything from scratch first you have create a new universe by creating another Big Bang....

  66. Scatch but don't sniff. by Anonymous Coward · · Score: 0

    I write my code from scratch in notepad: standard open source web-esque languages of PHP and Javascript, and sometimes I program Java with notepad.

    I have complete control over the program, thank... god.

  67. interfaces by feNIX77 · · Score: 1

    using appropriate design patterns and coding to interfaces (as spring strongly encourages) would completely prevent you from being 'married' to any particular implementation or persistence mechanism.

  68. Re:Reuse good code as much as possible by ShieldW0lf · · Score: 1

    It's worth mentioning, if you're going to use other peoples code, always wrap it up and call the wrapper rather than tightly coupling your own code to the foreign code. You never know when you'll want to replace it. The Bridge, Facade and Strategy design patterns are good for this sort of thing.

    --
    -1 Uncomfortable Truth
  69. reuse vs rewrite vs extending what you have by gullevek · · Score: 1

    I have learned through experience to always have a door open for those "non standard" requests. I always have them.

    So I have sort of my basic library set with functionality that will be always the same (eg debugging, logging, basic DB IO stuff, access rights to pages, basic template engine) and I built whatever I need on top. with this I reuse code, and extend it if there is need, plus I just need to write new code where it is needed.

    There is a very small chance that a standard framework will exactly do what you want. Or you just adept your needs to what the framework you choose can do. Both chances are normally very minor ...

    --
    "Freiheit ist immer auch die Freiheit des Andersdenkenden" - Rosa Luxemburg, 1871 - 1919
  70. Hibernate and Requirements by theunixman · · Score: 1

    They are not at all related. Seriously. And if you are getting requirements you think Hibernate can't fulfill, you have done something so fundamentally wrong somewhere that if you code the database layer yourself you will be completely screwed. So find out what the real problem is and what you need to change to work with Hibernate.

  71. Re:Reuse good code as much as possible by SL+Baur · · Score: 3, Insightful

    Stuff like Perl + CPAN is good because of all that code you don't have to write. The less code you write, the fewer bugs you make.

    Stuff like Perl + CPAN is also a very mixed bag and has likely caused my employer very much expense towards working around limitations in code therein compared to what has been gained. I know they've spent upwards of 6 figures on my time and others in direct and indirect costs working around the limitations and bugs in Storable, to name one example.

  72. Other Slashdot Articles... by raftpeople · · Score: 5, Funny

    On Wednesday we'll have: "I coded a project, and now it's all done, should I start another project?"

    Thursday's topic: "A lot of people around me use the tab key but I like to key in exactly 3 spaces for indentation, who's right?"

    And on Friday: "I...uuuuh...well....oh, have you ever hit refresh but the web page said it couldn't?"

    1. Re:Other Slashdot Articles... by TravisO · · Score: 1

      Wednesday's (today's) topic should have been:

      Obama is becoming president... discuss!

  73. Then you need the balls by EmbeddedJanitor · · Score: 1

    to tell them it is a new project. You should also make sure they change the project name so as to prevent confusion with the old and now dead project.

    --
    Engineering is the art of compromise.
    1. Re:Then you need the balls by syousef · · Score: 2, Informative

      Then you need the balls to tell them it is a new project. You should also make sure they change the project name so as to prevent confusion with the old and now dead project.

      Putting forward a good argument and suggesting that they start a new project may be the right thing to do. Trying to tell your employer what to do is stupid. Building a rapport and gaining their confidence isn't.

      It's not about having balls. Telling someone who employs you that they MUST do something your way is stupid. You don't have the power to execute your decision. At best you look foolish and the business harbour ill will at being told what to do. At worst, start looking for another job.

      --
      These posts express my own personal views, not those of my employer
    2. Re:Then you need the balls by Fulcrum+of+Evil · · Score: 1

      The words are a bit harsh, but some manglement has trouble seeing that massive changes in requirements can nullify most of the existing work; they need something more than the usual soft sell about what their changes mean. Sometimes they decide that they don't really need it that much.

      --
      "We returned the General to El Salvador, or maybe Guatemala, it's difficult to tell from 10,000 feet"
    3. Re:Then you need the balls by syousef · · Score: 1

      The words are a bit harsh, but some manglement has trouble seeing that massive changes in requirements can nullify most of the existing work; they need something more than the usual soft sell about what their changes mean. Sometimes they decide that they don't really need it that much.

      Before ridiculing them as 'manglement' you should realize that without a job they give you to do, you'd be out of a job. It really is worth being on management's best side if you can be. A team divided and all that. If they come to see you as an ally and trust you, your words will count for a lot more. If you're explicit and accurate about what the costs are it really is their job to make the final decision. You always have the option of finding alternate work if things go really badly or you don't believe your input is being considered.

      --
      These posts express my own personal views, not those of my employer
    4. Re:Then you need the balls by Fulcrum+of+Evil · · Score: 1

      Not really - we need management once we grow to a large enough size that communication is a problem; it's the workers who produce the product and make the value - basically, you've got things backwards. Anyway, I'm just saying that management needs to be brought round to reality - that's your job as the expert.

      --
      "We returned the General to El Salvador, or maybe Guatemala, it's difficult to tell from 10,000 feet"
    5. Re:Then you need the balls by syousef · · Score: 1

      Not really - we need management once we grow to a large enough size that communication is a problem; it's the workers who produce the product and make the value - basically, you've got things backwards. Anyway, I'm just saying that management needs to be brought round to reality - that's your job as the expert.

      Very few companies are actually run by the technical staff. You can't make someone who's higher in the chain of command do anything. So you either gain their trust so that they know if they don't listen to you it's at their peril, or you find a new company to start with. For a good company you need good workers and good management both. You also need everyone to work together. The us vs them thing is going to get you nowhere in life.

      --
      These posts express my own personal views, not those of my employer
    6. Re:Then you need the balls by Fulcrum+of+Evil · · Score: 1

      I don't do the us vs. them thing, but sometimes managers do. sorry you've never met a manager that needs a clue by four, but they do exist. Sometimes they thank you for saving their ass later, sometimes not.

      --
      "We returned the General to El Salvador, or maybe Guatemala, it's difficult to tell from 10,000 feet"
  74. You skipped over the first step by Hotawa+Hawk-eye · · Score: 1

    It sounds like you may have jumped or been pushed into the implementation stage early. The first step is to generate and agree upon the requirements for your application. Once you as the developer and your client know what your application will do (and more importantly what it will not do) you will be able to decide whether or not the code you want to reuse will satisfy your requirements (or can be tweaked to do so) or if you'll be better off building your own.

    Using a quote from the article: "It's starting to look like I would have saved myself a whole lot of time if I had written the database transaction using JDBC instead of Hibernate -- now that I'm married to this object model framework, some of this stuff doesn't look doable." If you and the client had sat down at the beginning of the project and described what the application must do, must not do, and what the client would like it to do (or not to do) would you have realized before getting "married to this object model framework" that some of the requirements would be hard or impossible to satisfy?

    1. Re:You skipped over the first step by julesh · · Score: 1

      If you and the client had sat down at the beginning of the project and described what the application must do, must not do, and what the client would like it to do (or not to do) would you have realized before getting "married to this object model framework" that some of the requirements would be hard or impossible to satisfy?

      In my experience, that only works on the rare occasions where the client actually understands their own requirements. More often than not, I end up telling the client what they need. In something like 90% of cases there's some critical point that neither of us understood in the beginning of the project that the client only realizes when he's sitting in front of the software, trying to actually use it for real business purposes. No amount of sitting down at the beginning of the project will fix this.

      You just have to realize that requirements change, and code to make the project easy to change later.

  75. Open heart surgery by UseCase · · Score: 1

    I whole heartedly believe in code re-use but I have been burned a bit by white box re-use. Be cautious of code you have to do open heart surgery on before it's usable! It's likely you'll be in there again and again.....

  76. Re:Reuse good code as much as possible by SL+Baur · · Score: 1

    Quality code depends more on the dedication of the developers on the project than it does on programming IQ (again, whatever that means).

    Programming IQ is defined quite clearly in _The Elements of Programming Style_, Kernighan and Plauger - http://www.amazon.com/Elements-Programming-Style-Brian-Kernighan/dp/0070342075

    It's required reading and the advice is timeless.

  77. Reuse the well done and code the rest... by benow · · Score: 3, Informative
    There are arguments for each.

    Reuse:

    • great choice for things done well, or for things not understood
    • reuse means for more maintainable code. It'll be far easier for another developer to come in and help out.
    • more stable and optimized
    • saves time (and, possibly, money)

    Homebrew;

    • great if you have time and dedication
    • you'll learn alot, which will help you with future evaluation. You'll also become a better coder.
    • your solution will fit the situation exactly

    The reasons behind reuse should make it your first choice, but at the same time, it's hard to be a great coder without coding. Turn that desire to code loose on the situations where the existing approaches are insufficient.

    1. Re:Reuse the well done and code the rest... by benow · · Score: 1

      Specifically for the project in question, try to work around the deficiencies... ie go to jdbc using the hibernate tables, etc.

    2. Re:Reuse the well done and code the rest... by benow · · Score: 1

      If you want to use my proprietary (lgpl'd) nastieness, check out my persistence framework.

    3. Re:Reuse the well done and code the rest... by TravisO · · Score: 1

      You totally forgot to list cons to each, and more importantly, to homebrewed (because programmers want to homebrew, they more easily overlook the cons).

      Reuse Cons:
        * May not be as flexible as you need

      Homebrew Cons:
        * Won't be as bug free & secure as an openly adopted framework
        * Might not be as fast
        * Not Invented Here (which has done unmeasurable damage to many companies, it's virtually the reason for Xerox's downfall)
        * Unmeasurable money/time blackhole

  78. Inversion of control by Requiem18th · · Score: 1

    My rule of thumb is that if it takes you longer to learn to use a tool than writing it your self you should probably just write it.

      But really code change is inevitable because reusable code isn't so always. For instance, I made a simple mysql wrapper because the senior programmer thinks ORMs are bloated, now that we have to work with oracle I made a different wrapper for oracle, he said that I should extend the mysql wrapper to handle oracle as well, but, the dialect of sql that oracle and mysql use are so different there is no chance we will ever swap DBMS.

      Rewriting is inevitable, I once read (in TDWTF) that any task that is done more than there is worth abstracting out.

    --
    But... the future refused to change.
    1. Re:Inversion of control by julesh · · Score: 1

      My rule of thumb is that if it takes you longer to learn to use a tool than writing it your self you should probably just write it.

      A good one. If you knew in advance how long it would take to learn the tool, that is. :)

      Rewriting is inevitable, I once read (in TDWTF) that any task that is done more than there is worth abstracting out.

      Sounds like a good rule to me.

  79. Re:Reuse good code as much as possible by Anonymous Coward · · Score: 0

    Depends. Not an expert on CPAN's code. But I've read enough PEAR to know how much it sucks. Avoid that crap like the plague. If you can't write code better than that, you shouldn't be writing code.

    However, the corollary to that rule of thumb is that if you can write better code than PEAR, you shouldn't be using PHP.

    Yet, If you understand the previous rule, then you are sufficiently intelligent to actually use PHP wisely.

  80. Impossible to say without knowing the domain by plopez · · Score: 1

    What is the problem domain? Is it a rapidly changing complex problem domain? Then you would probably want to "roll your own". If it is a fairly straight forward problem domain that is fairly static, use frameworks and other's code. This is a spectrum of course.

    My answer: whenever it feels right.

    But the entire problem with asking for advice like this is that without a context, the question is nonsense and so the answers will also be nonsense.

    --
    putting the 'B' in LGBTQ+
  81. Re:Reuse good code as much as possible by murdocj · · Score: 2, Interesting

    It depends on whether you are truly using well known libraries or not, and how much extraneous code you pull in, just to avoid writing code. You can end up with huge blocks of unknown, potentially buggy code that you haven't written, haven't read, and which may have unknown side effects, just to save writing a few routines. Using code you haven't written isn't always a clear win, it's a tradeoff, and you have to evaluate the costs and benefits, as you would with any programming decision.

  82. Libraries, not frameworks, for flexibility by Animats · · Score: 5, Interesting

    There are some advantages to libraries over frameworks. (Working definition: if you call it, it's a library; if it calls you, it's a framework.) Frameworks are great if your problem fits into the model defined by the framework. Since many web applications are rather standardized, that covers much of web development.

    The real problem with frameworks shows up when you need more than one of them in the same program. You can usually use more than one library, but using more than one framework is at best painful and often impossible.

    It's annoying when something which could have been implemented as a library is architected as a framework because frameworks are "cooler" than libraries.

  83. ASM by Anonymous Coward · · Score: 0

    This is why I write everything in Assembly. Need a new feature sure I can write that but it will cost ya!

  84. Hibernate by countach · · Score: 2, Informative

    Are you sure you can't use Hibernate? It has a lot of hooks. At least tell me you've read the book by the Hibernate author. I think you might regret bailing on it. Harder requirements need better tools to get the job done, not crappier tools like JDBC.

    1. Re:Hibernate by ChrisGilliard · · Score: 1

      Hibernate allows you to use straight jdbc calls which is what most people end up doing if they have a real world app and need to optimize the queries.

      --
      No Sigs!
    2. Re:Hibernate by julesh · · Score: 1

      Hibernate allows you to use straight jdbc calls which is what most people end up doing if they have a real world app and need to optimize the queries.

      Or you can use a stored procedure or sql query accessed via a hibernate named query. Avoids the need to get your hands dirty with JDBC, but allows you complete control over the query that's executed. Best of both worlds.

  85. I don't see the problem by zunicron · · Score: 0

    Using Hibernate does not tie you down to only using the ORM framework. You can still use JDBC if you need it.

  86. Choose a design that quickly gets feedback by Anonymous Coward · · Score: 0

    While everyone likes to bemoan the inevitable requirement changes that happen in a project, why not embrace that idea from the start? Given that there definitely will be requirements changes, you hope that they will come as soon as possible. After all, your job is to meet their requirements, isn't it? So you work in the way that will best do that. And the sooner you get feedback, the sooner you'll know what needs to change.

    So, reuse code if it will bring forward the time that the end user can see a working system and give you that feedback.

    And what makes a great developer is also writing the code in a way that minimizes the cost of those inevitable changes.

  87. What tools do you have? by istartedi · · Score: 1

    If you're a good "from scratch" coder, code from scratch. If you're a good "analyze other people's code" coder, reuse their code.

    I don't envy the guy who asked this question, regardless of what his capabilities are. He's experiencing the all too common "evolving requirements" problem. Evidently, the framework met requirements when it was chosen. Now it no longer does.

    Therefore, his real question is, "how do I throw away this beast with minimal disruption?". I mean, he's either going to do surgery on the beast (reuse) or replace the beast; but one way or another he needs a different animal.

    Bottom line? It's a judgement call, and it's based on the talents of you and your team. Me personally, I'd favor a quick-n-dirty full replacement in parallel with the existing code. Spend a few days of intense hacking. I'd know if it's workable after a few days. The mere act of coding the replacement will lead you either to conclude that the problem is not as difficult as you thought, or you will end up splicing the replacement code into the framework and, in essence... reusing!

    That's just me though. Then of course there's always the "I got me my 2 years of experience, let's put that on my resume and screw the next coder as I leave for a better job". That option doesn't work so well in a recession.

    --
    For all intensive purposes, "whom" is no longer a word. That begs the question, "who cares"?
  88. Programming IQ by ClosedSource · · Score: 1

    While I respect Kernighan and Plauger, I don't accept a definition of Programming IQ as a standard just because some smart and famous guys propose one. Plauger has forgotten more about C libraries than I will ever know, but he's been known to express opinions on aspects of programming that he knows little or nothing about. For example, claiming that there's nothing unique about real-time programming.

    1. Re:Programming IQ by SL+Baur · · Score: 1

      While I respect Kernighan and Plauger, I don't accept a definition of Programming IQ as a standard just because some smart and famous guys propose one.

      Did you ever read the book? Just asking.

      (Applying the sum total of the wisdom in that book as a definition of Programming IQ was my derivation, but I am certain it is correct and I've coded everything from device drivers to text editors).

      For example, claiming that there's nothing unique about real-time programming.

      It is clear that you have not read the book. Just about everything they wrote is applicable to real-time programming. You're forced to use tricky algorithms sometimes, but they still covered that.

    2. Re:Programming IQ by ClosedSource · · Score: 1

      The comments on real-time that I was referring to Plauger made in Computer Language magazine, not in the book.

  89. ORMs are the worst frameworks to use by cowwoc2001 · · Score: 1

    All frameworks (versus normal libraries) are problematic to a certain point of view, but ORMs are far worse. To understand why, read this: http://blogs.tedneward.com/2006/06/26/The+Vietnam+Of+Computer+Science.aspx

    If you insist on using ORMs, I personally suggest using JPA which abstracts away the underlying implementation and then migrating from Hibernate to EclipseLink. The latter implementation is much more solid and has a much healthier community.

    Hibernate's authors are notorious for being rude to their users and their code is notorious for the hard-to-debug exception messages they through. Just my 2 cents.

  90. Think different by AndiG72 · · Score: 1

    Maybe you should consider talking to an other programmer about your issue. It's possible that you just don't know how to solve your problem. There are great forums for spring and hibernate questions. And remember there are always many ways to solve a problem. If it isn't 'doable' like you said the one way, just try another approach to solve the problems. Maybe your problem doesn't fir into a technical transaction, try a logical one. Need distributed transaction handling - use JTA, with an XA datasource. But giving an advice without knowing the problem is difficult...

  91. Make the UI reflect the total state of the app by Matje · · Score: 5, Interesting

    Joel Spolsky wrote a nice article about this a while back. Since non-technical people don't see the code that's behind the UI, they can't really judge the difference between a polished UI with no code behind it and a fully working application. It is very reasonable for them to look at a polished UI and say "let's ship this tomorrow".

    The solution is quite simple: make the UI reflect the state of the application! Use sketched buttons for stuff that doesn't work yet, use strike-through text to label stuff that doesn't work, etc. I've been using this technique for years with my customers. It gets the point across every time.

    and don't listen to all that stuff about prototypes being proof-of-concepts, that's non-agile blatter from the 70's ;-). If the prototype is attractive enough that the business people would like to use it then you'd be wasting money by throwing it away and starting over.
    The fallacy behind starting over is that the prototype is a code mess and the rewrite will be clean. Forget it. If you're no good at refactoring and organizing code then the rewrite will end up a mess too. And if you are good at it, you should apply those skills to the prototype!

    1. Re:Make the UI reflect the total state of the app by TravisO · · Score: 1

      Also on a forum on Joel's site, there was a brief discussion on this subject just a week ago:

      http://discuss.joelonsoftware.com/default.asp?joel.3.692342.7

  92. Reuse, rewrite and recycle. by Kooty-Sentinel · · Score: 1

    Jeeeesus.
    Why does everyone always want to take sides? Do what works for you, not something that someone else thinks is right. If reusing code makes sense, reuse it. If you think the existing code doesn't meet the requirements, rewrite it! And if you think you can make the existing code meet the requirements, recycle the code!

    --
    Your evaluation period for Productivity 1.0 has ended. Please purchase more coffee to continue using this product.
  93. OP doesn't utilize Spring to it's full potential by 4ntifa · · Score: 1

    The fact that the OP's application logic and data access code are tightly coupled reveals he doesn't use Spring Framework to it's full potential. One of the fundamental ideas of Spring is to program by interfaces and decouple the actual implementation from the interface, and configure the implementation declaratively.

    If he had designed his application properly, changing the data access implementation would be very unintrusive to the rest of the code. Actually, transactions could be also defined declaratively, further decoupling them from the data access code.

    Whether or not you're rolling your own or reusing isn't as important as knowing the tools you're using!

    --
    -=- 4ntifa -=-
  94. Abstraction gives you room to move by crowne · · Score: 1

    The libraries that you have used have provided additional value that should be factored in ... documentation, knowlegable community, database independence etc.
    This has come at a cost of pushing you into a code structure in which you currently feel restricted.
    What I like about Spring is that it acts as kind of an uber-Factory, so if hibernate is not working out for you, you should be able to refactor to another persistence mechanism fairly easily, because the implementation is hidden behind the service that is exposed by Spring. You can then change the implementation using new frameworks, and as long as the signatures / interface dont change then the calling functions will be unaffected.
    You may want to consider swapping your hibernate implementation for iBatis see Hibernate vs iBatis
    What I dont like about Spring, is that I find it sometimes difficult to piece together a decent mental model when first looking at an existing application from various bits of xml which may or may not have dependencies between one another.

    The libraries that have been abstracted at a higher level e.g. Hibernate or iBatis as opposed to jdbc exist because add value by solving common issues. They are successful because of the open communities that spread the knowledge outside of any single organisation. Beware of the danger when writing your own, that you may end up at a later stage having to solve issues that have already been dealt with by existing frameworks.
    Good Luck, Neil.

    --
    RTFM is not a radio station.
  95. Good business patterns by Anonymous Coward · · Score: 0

    Loosely coupled modules and a solid SOA setup and these problems wouldn't exist.

    With solid Data, business etc layers you could just have changed the dbase and dbase code in the bottom without the top caring or even knowing.

  96. Since you're using Java ... by Qbertino · · Score: 2, Interesting

    ... I'd say don't programm anything yourself unless you are abolutely sure it doesn't exist in some form of lib or class. Programming in Java is a PITA as it is, and it's whole point is that you don't have to build anything yourself.

    In fact, Java is nearly not at all about programming but about reading docs and integrating libs and classes that provide the code you need. It's OOP Forte with the brakes removed, and one of the reasons it's considered to be so outright boring. That's why there are so many thriving alternatives such as PHP or Python, so that people can get a chance to do some result oriented coding.

    You are in Java territory allready and Java now is free (speech) aswell, so continue to play the Java game and learn as much as you can about it by integrating existing code. Java-style research, doc-reading and OOP knitworking is tedious but in the end it'll pay off. Especially if you plan to advance in an suit-style big-bucks IT career. There's a reason any other PL can't get by OOP and/or the Java way of doing things beyond a certain point if they want to be taken for granted.

    To go even further, I'd actually look into UML editors and CASE-Tools once you know your way around Java, as these are the most advanced in the Java world and mark the point beyond which Java loses its pain factor. I find JBoss and jBPM BPEL, JPDL and GPD particularly interesting. (If you allready feel sick reading those abrevations, then you know why a large part of me still avoids Java whenever possible :-) )

    My 2 cents.

    --
    We suffer more in our imagination than in reality. - Seneca
  97. Re:Reuse good code as much as possible by renoX · · Score: 1

    >>Actually, the trick is knowing that you _aren't_ a great programmer (honestly what are the odds that you are a great programmer?), and thus choosing to reuse code from better (and hopefully great) programmers.

    Uh, the code you reuse isn't necessarily from great programmers, nearly all the Perl code I've had to maintain was a POS: either it was created by beginners making lots of mistake or it was created by experienced coders who think that TWTOWTDI is a great way to get job security and creates unmaintainable code: I remember one case when a colleague of mine call me because he was trying to understand a Perl script written by an "expert" and he was stuck with two lines of code: it took me 30 minutes and 2 books (and lots of swearing) to rewrite those 'magical' two lines with ... two lines(!) that a beginner in Perl could understand..

  98. Re:Reuse good code as much as possible by Anonymous Coward · · Score: 0

    What is the UL approach? Links?

  99. More fish in the sea by Anonymous Coward · · Score: 0

    hibernate ain't the only persistence layer library ya know. OJB, torque, blah blah blah.

    But reuse is still better - just sounds like you need to open your horizons on other alternatives.

    Oh yeah, and stop letting the requirements creep.

  100. Re:Reuse good code as much as possible by Anonymous Coward · · Score: 0

    Then what if you redefine "great programmer" as "a programmer who consistently produces quality code"?

    I think you mistakenly equate a "great programmer" with a "smart person" but that is not necessarily the case.

  101. Framework != reuse by famebait · · Score: 3, Interesting

    Lots of good advice already, but I want to add one thing:

    There is a difference between frameworks and other libraries.
    Libraries are a no-brainer; you just don't go and write a
    replacement unless you have very weird requirements.

    But frameworks tend to dictate how your app is structred,
    and to some degree even what it does, and that can be severely
    limiting. Frameworks vary in how easy it is to deviate from
    the assumed flow of things, but you can indeed find yourself
    spending a lot of the time fighting a template that just
    doesn't fit your task.

    Before you drop it, especially if it is much respected
    by other good developers, make sure you really understand it
    and what freedoms it does offer you. But if you discover
    it simply has a different goal than you, the sooner you
    get out the less waste you have to grieve about later.

    --
    sudo ergo sum
  102. Re:Reuse good code as much as possible by TheLink · · Score: 1

    Sure, that's why I said reuse good code.

    BUT where do you start looking for good code?

    You are more likely to find good code from a programmer with a track record of producing good stuff, than from a programmer with a track record of producing crap.

    Average programmers might be able to eventually produce quality code, but it can take them 10x or even longer to do so. Some programmers will take 3 years to do something that others can do in a day. So if anyone is thinking of assigning a rating to programmers, a log scale might be a good choice.

    If you ever come up with a system that somehow produces good code from crap programmers in a timely manner, you may have solved the AI problem or at least be making better progress than most AI researchers ;).

    --
  103. Re:It's knowing when ... Profit! by pbhj · · Score: 0, Flamebait

    a great programmer can:
    1) Evaluate the suitability of existing code for the task
    2) Use the existing code appropriately
    3) Write excellent readable, maintainable code when needed (and only when needed) to fill the gaps
    4) Communicate well with the business to understand the problem and design a solution

    5)...
    6) Profit!

    I wish I was a great programmer then I could cure world hunger, poverty and conflict and walk on water in my spare time ....

  104. Subtle Differences by Zwitta22 · · Score: 1

    I wouldn't necessarily call using a framework code re-use per se; more code generation... I'll admit that it is using someone elses code, but as you have found out, frameworks usually have pretty tight limitations (which is fine if you have a project that you know will not have a requirement change in it's lifetime), either that or they attempt to allow for everything and as such become more complex and messy than simply using the language in a vanilla form. Great programmers build themselves job specific factories, classes, modules, includes (whatever container you use in your specific lingo) and re-use them in other applications... Teams of great programmers build themselves a communcal collection of packaged code and libraries which perform the common business logic or UI elements frequently used in that company or group :)

  105. Beyond the capabilities of those frameworks?? by iwein · · Score: 1
    (disclaimer: I work for SpringSource, but do have my own opinion)

    So let me get this straight: you have used a framework that allows you to mix and match the use of your ORM solution with plain JDBC. It also has a dedicated WS project that isn't bad at all and you happen to need that too. Sounds like a good start to me.

    The fact that you now have to write some code yourself is not a shortcoming of the frameworks you used, but a natural step in the evolution of any useful piece of software.

    I'm biased because I'm a committer to Spring, but you can't seriously argue that having to extend Spring is an argument against using it.

    I would say that the extensibility is one of the main strengths to look for in a framework, for exactly the reasons you're stumbling upon.

    It seems like you've written an application that is actually used and now the users want more. Congratulations!

    --
    Show a man some news, distract him for an hour. Show a man some mod points, distract him for the rest of his life.
  106. Re:Reuse good code as much as possible by HnT · · Score: 1

    This is a similiar flaw to believing that ISO certification means that a company will always create great products.

    It is a common misconception that an ISO certification certifies the actual product quality in any way.

    Those standards and a certification received from ISO does not in any way certify the actual, highly subjective product quality perceived by the customer. Rather, it consists of rules and guidelines which your business processes and business process descriptions have to adhere to - e.g. you need to have a process description at all, to begin with, and it has to be accurate, people should "live it" and there should be means of continual improvement, you need to keep track of defects etc.

    Generally speaking, you could produce highly defective foobar and still be ISO certified - of course the ultimate goal of all that process yadda yadda has to be to finally improve your products and/or make more profit but in itself ISO 900x certifies the quality of your red tape - you know, those documents nobody would usually touch with a 10ft. pole if it wasn't for making it through the much-loved re-certification.

    clicky

    (I am assuming, of course, you were refering to the iso 9000 family of standards)

    --
    "Only one thing is impossible for God: To find any sense in any copyright law on the planet." - Mark Twain
  107. Re:Design First Then Build... It Just Never Happen by julesh · · Score: 3, Insightful

    The problem is, most people/organizations desperately want to build something now, so they feel something's happening, then keep tweaking it all over the place until they're happy, totally changing the spec once it's underway.

    Actually, if it's done right, that's the best thing to do. Why? You produce a first release _quickly_ without having to worry about the features that are several versions down the line. That release is adopted and the customer starts actually using it. Whatever happens, they're now actually getting the benefit of having the useful software that you have written for them.

    And sure, they might decide that it's wrong in some critical respects. But at least they have _something_ to work with while you're making the changes they requested.

    Most systems aren't like that. They're designed by committee who won't think through most issues until they see a working version. They essentially force prototyping on you - yet consider what you're building the final system and won't pay for you to do a final rebuild.

    I've never had a client who expects to get free changes to the working software I've delivered that meets their original spec, even when they decide it's not what they wanted. Well, OK, there was one. But the court agreed with me and made them pay up. That's in over ten years of professional software development. I've had clients who ended up with bills nearly double what they originally expected, but they've paid happily because they knew I delivered their original requirements, but those requirements changed. They know I charge per feature developed, and I always make sure they know before I start work on it what each feature will cost. Generally speaking, they're all happy with that.

    Yes, code re-use is something great programmers do. But only if they have great designers who really think everything through first.

    Some of the best code reusers I've come across are agile developers who espouse not thinking through anything beyond the feature you're working on at the moment. Reuse doesn't require ahead-of-time design, but it does require a lot of attention to detail. In the OO world, it requires a good understanding of design patterns (which means when not to use, as much as it does when to use them). It requires the ability to understand what your code is doing in great detail, and to hold a large chunk of that information in your head at once, to enable you to spot where another piece of code is doing something similar to what you're trying to do now. It requires you to have sufficient confidence to rework that old code to better fit its new application, where necessary (which normally means you'd better have good test coverage of it). But it doesn't seem to require you to identify the opportunities for reuse in advance.

  108. My advice: don't code by SlashDark · · Score: 1

    You should get most (preferably all) of the resuests before you start coding. And you should get them clearly. If you start coding and accepting more and more requests you'll end up in trouble. When you start a project, make sure it's been talked about enough, good descisions must have been made etc. Then write down what needs to be done and what the resulting software should have. Whatever is -not- in there ... is too bad. They should have thought of that earlier, or pay you for all the trouble you need to go through.

  109. I prefer by Anonymous Coward · · Score: 0

    a hybrid approach: reuse something and rewrite it partially to suit my needs.

  110. Re:Reuse good code as much as possible by Anonymous Coward · · Score: 0

    It's worth mentioning, if you're going to use other peoples code, always wrap it up and call the wrapper rather than tightly coupling your own code to the foreign code. You never know when you'll want to replace it. The Bridge, Facade and Strategy design patterns are good for this sort of thing.

    If wrapping it up means taking a performance hit and if it is a no-go, then make "contact surface" between your and foreign code small, so that you rewrite only minimal part of your code.

    Remember that inevitably there will come time of finger-pointing and have mechanisms ready to easily prove that your code works well and who is to blame.

    Also, keep in mind that there is no good reason to trust yourself too much, either! When writing part of your code, be suspicious to other parts (you also wrote) like if it was foreign code. At some point, it may become so, some of it may be "offloaded" from you and given to someone else to work on it, and it could become hell for all of you. This attitude will naturally result in clean and functional interfaces between your modules.

  111. Be an Architect! by Anonymous Coward · · Score: 0

    Actually, these sorts of creeping-feature problems are best solved in the design process. What we like to do (I am not a programmer, but I work for an IT company that has a team of programmers) is create a complete formal specification of exactly what the app will do, with mockup screen shots, sample reports, etc, listing each and every individual function and feature. Once you have thought out the end product, and gone over this design in excruciating detail with all of the stakeholders, everyone involved will know exactly what you are going to produce, and what it will do. I like to think of good software development like constructing a building. You need to get an architect to produce a detailed and complete set of plans before construction begins. You would not hire a contractor, and begin describing the building to him, and then have him immediately begin building it. The building built in such a way would most likely come in over budget, be a mass of repaired mistakes, and might not even pass the local building code. When you are one person tasked with designing and building a piece of software, put on your "architect hat" and do up a design. If you design properly, you will drastically reduce the amount of time it takes you to actually write the code. Your brain will have already worked out to some extent how the project will be put together, and since you have a good set of blueprints, you will not end up scrapping whole modules and rewriting them because you forgot to account for the consequences of some piece of code you had not yet considered.

    On the subject of frameworks, libraries, etc: They are the building materials. It should be fairly evident from the design what kind of materials are appropriate. You do not generally build houses from reinforced concrete and sheets of glass, nor do you try to timber-frame a skyscraper. Use the "materials" which will make the project plan come together well. By the time a good spec is written, you should know what that is, if you have some experience with various "materials".

    Also, a good design document is a decent start on some rough and ready documentation. That set of plans will help the next developer who must work on the plan, because the purpose of the software and all of its various operations should be laid out there. If you take to this philosophy, then new modules or features should have their own addendum, or an updated design document should be produced as part of the maintenance process.

  112. Asking the wrong question... by Anonymous Coward · · Score: 0

    I guess I'd ask the OP how good he is at Hibernate.

    I can't imagine somehow "outgrowing" it and needing to rip it out alltogether when it manages to fit for some of the largest companies and projects enterprise has to offer. If you come across a query that needs to be hand-coded, fine, do that, Hibernate supports that. But why would you need to write your own ORM tool?

    Job security?

    1. Re:Asking the wrong question... by DuckDodgers · · Score: 1

      Seconded. Learning Hibernate was really difficult for me. But now that I am comfortable with it, I can make it manage all sorts of intuitive and not-so-intuitive tables and table relationships.

  113. The Rule of Three by fartrader · · Score: 1

    My PhD is in software reuse and the main lesson is, never approach a problem with "I am going to reuse something today". The classic mantra is the rule of three, if you find yourself building something for the third time, capture it (and the other two) as a generic component and reuse it in subsequent scenarios. With respect to existing components/frameworks if it does what you want great - otherwise you need to ask yourself the question - "will changing it to meet my needs be quicker than building it from scratch?", if that's the case then reuse, otherwise do it yourself.

  114. Logical Coherence by anorlunda · · Score: 1

    Truly great code has logical coherence. It embodies a concept pure in conception and internally consistent in implementation.

    To produce great code you need two things. First, you need inspiration. If you don't have that, then methodology doesn't matter. Second, you need to be able to transform the inspiration from the moment of conception to a complete, debugged, tested, and integrated deliverable in a single session. In that session your brain must hold the concept in its entirety without losing track of any details. That means an uninterrupted session of 20 hours plus or minus depending on your age.

    Sorry, I can't find the link to the Hacker's Dictionary entry for this. It claimed that all truly great software was the result of giving up and restarting from scratch multiple times. Early iterations serve to teach you what the real requirements are. Also, your recent familiarity makes you much more productive in the second and third iterations. You may be able to produce 5 times more in the second iteration, and 10 times more in the third iteration because you're in the groove.

    To be successful at iterations, the time elapsed between iterations has to be really short. Indeed, sometimes inspiration for iteration N+1 comes before N is finished. What they were trying to teach you in the hacker's wisdom was that if that happened, start over rather than trying to alter course.

    Well times change. Today we deal with much larger, more complex, and more integrated applications than were typical in the 60s. ALso, development time is stretched over weeks and months, and rapid consecutive iterations are impossible. At the larger scale you are forced into reuse.

    Still, there is no conflict of ideas. You can still strive for logical coherence and no-reuse policy at the module/object level, while applying re-use at higher levels. One of the great benefits of object-oriented design was to aid in limiting unintended consequences of complete replacement of the implementation of some objects.

  115. Good Programmers Abstract by smartin · · Score: 4, Insightful

    Where possible, you should never expose your choice to use an underlying technology. Instead wrap it in an Interface that exposes the functionality that your application requires and hide the implementation from the rest of your work.

    --
    The difference between Canada and the USA is that in Canada healthcare is a right and gun ownership is a privilege.
    1. Re:Good Programmers Abstract by freedom_india · · Score: 1

      Make it a point to get a diploma in the book Code Complete.
      I have the first edition, and even 12 years after buying it, i STILL discover a new idea or good teaching in that book.
      Some days, when it is snowing hard outside, and the TV is on the blink,
      and the radio throws out random hijinks,
      and all the other books have no meaning,
      i open a random page in this book,
      to learn a new thing that i not forsook,

      sorry about the rhyme less lyrics, its just that i had a hard day today, and i love the aged book very much.
      Surprising is the fact it comes from Microsoft.

      --
      "Doing what i can, with what i have." ~ Burt Gummer
  116. Re:Reuse good code as much as possible by Hognoxious · · Score: 1

    Those standards and a certification received from ISO does not in any way certify the actual, highly subjective product quality perceived by the customer.

    Of course not, the customer's opinion is (as you say) subjective. If isn't subjective, it's probably unreasonable, uneconomical or downright physically impossible.

    Generally speaking, you could produce highly defective foobar and still be ISO certified

    You can make lead lifejackets - as long as you write it down.

    --
    Confucius say, "Find worm in apple - bad. Find half a worm - worse."
  117. Re:Reuse good code as much as possible by Hognoxious · · Score: 1

    That's pretty profound. You should try and make it into a haiku or something.

    --
    Confucius say, "Find worm in apple - bad. Find half a worm - worse."
  118. Re:Reuse good code as much as possible by Anonymous Coward · · Score: 0

    "There's no such thing as a "great programmer" in the sense that one individual excels in every aspect of software development. Average programmers (whatever that means) are quite capable of producing quality code." - by ClosedSource (238333) on Tuesday November 04, @09:55PM (#25635839)

    Excellent, & accurate, imo @ experience in this art & science/field!

    As Hancock (Will Smith) would say?

    "GOOD JOB!"

    (Perfect reply, & agreed upon here, 110%)...

    Heh - 2 days ago in email, after hearing from an old friend online again (he & I have common ground in this field in OS tuning/tweaking for speed + security, etc./et al) & I wrote pretty much the same thing to he!

    (He hosts a technical forum in ashentech.com - nice person, good techie too )

    In that correspondence, I told him:

    "It's all work, there is no 'greatest programmer', & very few of us are 'naturals' at it - we all hit those 'tough spots' in things we haven't done before, OR, where there is no 'turnkey prebuilt solution', such as ActiveX controls, .NET assemblies, VCL controls, or even DLL/lib prebuilt proven API calls that can do the job, by merely calling a prebuilt function or using a prebuilt tool... you have to invent it, yourself, many times... & this? This is work, no questions asked!"

    Thus, based on your reply + the thoughts of others here as well... well, it is good to see that others feel (and doubtless KNOW, from hands-on experience) this is the truth of the matter.

    ----

    "Quality code depends more on the dedication of the developers on the project than it does on programming IQ (again, whatever that means)." - by ClosedSource (238333) on Tuesday November 04, @09:55PM (#25635839)

    Amen!

    Edison said it, best (though I respected Tesla his "rival", a 1,000x more):

    "GENIUS IS 1% INSPIRATION, 99% PERSPIRATION!"

    APK

    P.S.=> Anyhow? Yay Democracy, yea USA!!! OBAMA for the win!

    ( & the man plans on cutting outsourcing & that means that us guys in this field, especially THIS arena (coding) will be hopefully getting the best paying jobs BACK here on our shores, rather than some exec or project lead outsouring it oveseas (all the while, w/ said exec charging his company, say, $150/hr., paying an Indian, Chinese, or Russian fellow $5 of it, & the exec pocketing the rest himself AND putting security @ risk because who KNOWS what kind of 'backdoor' could have been built into the code & yes, this is a potential danger as well))... apk

  119. In defence of DIY by Anonymous Coward · · Score: 0

    I was using Hibernate/Spring on a project up until 6 months ago and found that I was spending a lot of time dealing with memory running out in Hiberate and fixing errors in my Spring xml configuration. I ripped it out and replaced with JDBC and since then my productivity has gone up a lot.

    This is NOT suggesting that you do the same. I think it was a good idea in my position for the following reasons:-

    1) The amount of data being persisted was small (only one class with a bunch of fields) and is very unlikely to grow much in the future. Most of the logic of the system did not need to interact with the database (it manipulated it and interacted with other systems/files). Hibernate helps by persisting your classes without you having to do much extra work, so doesn't save you much time/code if you already know how to use JDBC and only have one class.

    2) I made sure this persistence was done through a java interface (a DAO = Data Access Object) to a class without using any JDBC specific classes to commicate with it, so that the implementing class can be easily replaced with Hibernate or another persistence mechanism without having to change any of the other main system code.

    3) Our company is not into training and none of us had training in Hibernate/Spring. This meant that I may have been making mistakes with the use of the framework and I had to spend some weeks learning the hard way about some assumptions hiberate makes. If your company puts you and all your colleagues on a training program for every major thing you use then this is a reason to favour these kinds of frameworks.

    3) My application uses a LOT of data and so has to be very good at clearing up memory. Being able to see how memory is allocated and freed in my code (not deep withing the Hibernate Framework) is important. It also needs to be very fast, and so direct JDBC access may be faster than using Hibernate classes.

    4) There are only ever one or two developers working on a product like this in my company and so its not as critical to use the de-facto standard that most developers have used before.

    5) Hibernate (and all the other frameworks) have had plenty of bugs in their time. True, they mostly get fixed after a bit, but if my small one class to persist my data has a bug or performance issue I can fix it today. With a framework I can spend weeks on the bug fixing forums trying to get them to recreate and look at my edge case problem that blows up my system (not so important to them, but critical to me). My system may have been running out of memory because I wasn't using Hibernate "properly" (maybe if I used a different type of setup parameter it would have worked) or it may have been a genuine bug with hibernate that only occurs under my kind of circumstances (so very few other people see it). By spending 3 days ripping out hibernate and replacing with a small class I saved wasting further weeks on the problem.

    In a lot of the replies above people have been sneering at do-it-yourself idea, but in specific situations it really makes sense.

    With regard to Spring I can especially see the benefits of Spring on large projects with lots of teams of Spring-trained people who need to link up their code and have Spring xml file editors in their IDE. Or in companies with higher staff turnover of Spring-trained employees, so that a new person can come in and see how a system is wired together.

    On a small project with one or two developers who have no previous Spring experience or training and a reasonably straight forward system AND low staff turnover it may not be worth converting to Spring. KISS.

  120. Loaded Question. by kcdoodle · · Score: 1

    Define "From Scratch".

    Remember the quote -- "To make a pie 'From Scratch', first you have to create the Universe."

    Each programming tool you use (even assembly language), uses a tool the somebody else wrote. The real question for this article should be -- "What level of abstraction are you comfortable with coding?" - OR- "Which tool most closely addresses your problem space without undo limitations and has the least amount of bugs?"

    Personally, I have wandered through the various levels of tools. I have made my own web server (really weak, but functional for ONE purpose), my own web crawler, my own search engine, and then I have used tools that do it all for you -- WSDLs are so darn easy, using any DB beats making your own, embedded browsers, its all a mash-up, but, you get the idea.

    Do whatever is best for the specific project, if you find out you were wrong, fix it. You just learned a great lesson, there will be many more, -- and a test at the end.

    --

    - I live the greatest adventure anyone could possibly desire. - Tosk the Hunted
  121. Great Programmers by DriveMelter · · Score: 1

    I think Great Programmers write reusable and extensible code, it only takes an average programmer to reuse code, I know because I am one. I've seen this from the CMS perspective, there's plenty of them out there and plenty of them can be extended. Its when you start pushing them to the limits that you find which ones are really written to be re-usable and extensible and which ones have the component parts tightly coupled and when you start pulling on one thread (sorry for the pun) you get a whole spagetti of mess.

  122. LIKELY YOU WONT GET THIS FAR... by cjhanson · · Score: 1

    But if you do happen to make it to my comment, I have a potential solution for you. If you need to extend the framework to meet the new requirements, look into AOP. It will allow you to specify behavior and attach interactive code to anywhere in the call graph. A good example is caching. Say you framework didn't support it, but now they want it... you can point-cut the object hydration calls and (quickly) build a caching system and subvert the original call, or continue the original call flow, all under your precise control.

    AOP is honestly, imfho, the best evolutionary leap in software design since OOP.

  123. Great Programmers Write it from scratch by olddotter · · Score: 1

    You can have a biscuit out of a can (or tube) and some of them are good. Or you can have a scratch made biscuit. The best programmers I know either writing from scratch or modify the OSS libraries to do what they need.

    Sometimes it is faster to write from scratch rather that learn to use the tool kits out there.

  124. features by Anonymous Coward · · Score: 0

    You have to have balls and say this is not what you ordered if you want this feature thats a new app and for x amount of money i will be glad to make it for you too.

  125. You may be able to salvage much of what you have.. by Anonymous Coward · · Score: 0

    We had a similar problem in that Hibernate was just not going not work with the data model we inherited (unless we did some major customization). We had successfully used Hibernate & Spring for our proof of concept, and we didn't to throw things away!

    Enter iBatis: it let us maintain the framework and rewrite data access layer VERY quickly. It might be worth a look.

    FULL DISCLOSURE: We are using the .NET version of Spring, Hibernate and iBatis.

  126. I always reuse by crodrigu1 · · Score: 0

    How I develop code: 1) write helper libraries 2) build on top of the libraries 3) extend the libraries when needed not the code 4) the upper layers are very specialized 5) lower layers know only to do a single verb I keep using the same code that I wrote for java 1.2 This rules means that the code is very decoupled and that is one of the most important rules (when you use a framework you are tied to what the framework can do and too many times you need to broke from the framework.

  127. More detail please... by OdinOdin_ · · Score: 1

    I know both these frameworks very well; I find it hard to understand how a customers/employers requirements can creep in such a way that either of these two frameworks as a solution get in the way of the underlying problem.

    Both frameworks are additive to the underlaying standards. Hibernate additive to JDBC so can be used in conjunction with, instead of or even a healthy mix of both. Spring (for web-apps/web-services) is additive to the Servlet specification and can be used in conjunction with, instead of or even a healthy mix of both.

    Neither mask, hide or remove the underlying technology features.

    There does not seem to be any original article explaining the dead-end you have found yourself at when using either/both of these technologies. Maybe you should blog this so that slashdot fans can better understand your plight. I'm sure the respective authors and maintainers of those frameworks really do want to listen so such cases and improve things for the next iteration.

    Unless of course you have a customer/employer who is now asking for your framework to land on the moon (the "moon-on-a-stick" requirement).

    I understand your question was attempting to be a general developer question but it does seem you are unsure which avenue to take right now and you are asking the world for help. So please blog your plight.

    When you're a good developer the answer is obvious. So lets see where the problem verses solution you created whet wrong so we can help make you a good developer.

    1. Re:More detail please... by Todd+Knarr · · Score: 1

      Usually it's additional requirements for a non-normalized data model. You design a nice clean data model, and then business throws in a requirement that forces you to read part of the object, look at what's in it and make a decision on how/where to get the rest of the object before being able to read it. So now you've got business logic, and information only available to the business layer, buried down inside your persistence layer controlling how objects are represented in your database. Of course the right way to deal with this is to change your data model to match the requirements, but you can't do that since there's now other applications that depend on the database schema and you're not allowed to break them or force them to change. So now you've got an operation that needs to be atomic but that involves a set of steps that, in Hibernate's universe, aren't atomic. There's several ways around the problem but none of them are pretty and they're all time-consuming, more so than management will allow for.

  128. If you're asking this question... by Slashdot+Parent · · Score: 1

    If you're asking this question, then you did it wrong.

    The whole idea of Spring is that it is agnostic regarding which technologies you use. You should be able to swap out Hibernate and replace it with JDBC without affecting anything beyond the data access layer.

    I recommend you just stop everything and read a good book about Spring before you dig this hole any deeper. Or just don't use Spring at all if you don't want to use it properly.

    --
    They don't grade fathers, but if your daughter's a stripper, you fucked up. --Chris Rock
  129. Out of curiosity... by filterban · · Score: 1

    Out of curiosity, what exactly are you trying to do that Hibernate isn't solving? Is it some database-level craziness with stored procedures or something?

    Hibernate, while not perfect, meets the vast majority of my needs... and for the 0.1% of the time it doesn't, I can always write my own persistence layer.

    Code re-use will make you look good when future requirements come up. For example, what happens when you decide to move to MySQL to get away from Oracle, and all of your code is using JDBC with hand-coded SQL? You'll be spending weeks changing that stuff when Hibernate would have abstracted away the vast majority of issues.

    Ideally, the best way to avoid bugs is to code smartly and minimize lines of code. Re-using industry standard libraries and frameworks like Hibernate and Spring lets you do that.

    --
    rm -rf /
  130. Takes the best of both worlds by e70838 · · Score: 0

    Frameworks are great for rapid development, but are bad in the long run (as you explained better than I would because of my broken english).

    I think that you should advertise the project developped with a framework as a prototype release (even if it provides the full specification). If the project is successful (many projects are disgarded because the specifications were wrong) and needs to be maintained, the migration to "own made software" can be scheduled and the workload is easier to justified.

    People are very reluctant on the idea of "throwable software", but mistakes could be avoided by a prototype before deciding software architecture.

  131. The Unavoidable Car Analogy(tm) by TravisO · · Score: 1

    Marketing says... "We want to start building our own cars, you're an experienced car designer, we already have a factor ready so you should be able to design and begin producing in 8 months" and let's say they're right, fairly reasonable.

    Then after all that they throw in, maybe 4 months into the project "oh yea, 'green' is in now, so we can't use that gasoline stuff, make it run on solar cells".

  132. Obvious car comparison by euice · · Score: 1

    If you just want to build a cheap car, reuse parts. If you go for mass production or want to build a Ferrari, start with stock parts and redesign them where necessary.

  133. Just some points to consider by amn108 · · Score: 2, Interesting

    1. Reuse if a maintained, actively developed component exists that provides the functionality, especially if the component is advertised for reuse - i.e. a library made for linking.

    2. Reuse if you know you know less about implementing needed functionality than you plan to spend time and energy learning. Some things do need time to learn, and the mere programming skills do not help much if you are expected to dig into documentation of different standards and hardware specifications.

    3. Reuse generally when any solution already exists, because wrapping up a bad component through a flexible interface is better than tightly coupling self-developed component. Later you may replace the mediocre component with a better candidate, but will retain the interface, so minimal changes will be required to your product.

    4. Reuse generally, because through wrapping up a piece of foreign code, will give you the benefit of unit-testing, since the chance of even a mediocre foreign component working better than your first attempt to replicate its functionality is fairly high. This gives you two advantages, the one described at 3. and the benefit of said unit-testing.

    5. Rewrite if you plan to after-maintain the developed component you otherwise would reuse from somewhere else, especially if you will consider giving it its own life as a standalone generic solution.

    6. Runtime linking is teoretically a better idea, however practically, almost every time the version of the linked library changes, the whole product suffers due to degrees of incompatibility with the said library, however promised its version compatibility. This unfortunately happens much to often, one of the reasons many seasoned developers prefer to embed code at compilation time, thus eliminating the runtime incompatibility problem. They make up for it by frequently (or infrequently, pick yours) recompiling and publishing their host product with the updated library version re-compiled into it.

  134. Its like shakespere by speedplane · · Score: 1

    To reuse or not to reuse... that is the question

    --
    Fast Federal Court and I.T.C. updates
  135. Great Programmers and Code Reuse by solprovider · · Score: 1

    Actually, the trick is knowing that you _aren't_ a great programmer (honestly what are the odds that you are a great programmer?), and thus choosing to reuse code from better (and hopefully great) programmers.

    There's no such thing as a "great programmer" in the sense that one individual excels in every aspect of software development.

    1. Being a great programmer is overrated. Producing more than 10 times faster does not result in earning 10 times faster. The pay rate for the great programmer is rarely double the rate for the normal programmer. The benefits of using a great programmer are reluctantly taken by customers. Projects budgeted for one year costing over $100,000 are completed in one month for $20,000, are better aligned with the business, provide more functionality, and are easier to maintain; customers still complain about the higher rate.

    2. Great programmers could excel in every aspect of software development. That stated, we are humans with personalities including individual preferences. In the late 1980s, I thought about creating a Unix-like OS, but decided I would dislike creating and maintaining the project. Luckily, others with different preferences had similar plans resulting in Linux and the BSDs. My preference is application platforms, one level below building applications. My chosen specialty requires being expert at building applications and integrating with many systems (operating systems, databases, and clients e.g. browsers.) Does anybody think that RMS or Torvalds would have difficulty programming games? Their specialties derive from personal preferences, not abilities.

    3. Great programmers will join existing projects. Using a popular project removes the work of creating and marketing early versions. A great programmer focuses on fixing problems with the software, including redesigning and rewriting whatever is needed to make the project do what the great programmer wants.

    4. The OP has discovered that new specifications are difficult with the chosen framework. A normal programmer starts looking for a new framework. A great programmer has more choices:
    - Work around the problems without discarding the current framework.
    - Fix the current framework to handle the new requirements.
    The former is possible because the great programmer does not accept the limitations of the framework. The latter is possible because the great programmer can quickly rewrite the framework without adding much to the project's budget. Normal programmers are more accepting of limitations, less likely to design workarounds, and cannot rewrite the framework in a reasonable timeframe.

    5. Almost nobody builds "from scratch." Even if the OP discards the current framework, he will still use existing Java Web servers and operating systems. The choice is not whether to use others' code, just how much.

    6. Solutions include:
    - Building a new framework.
    CONS: High maintenance, less expertise, future requirements may still exceed the capabilities.
    - Switching frameworks.
    CONS: Future requirements may still exceed current capabilities.
    - Fixing the current framework.
    CONS: Need to have improvements accepted by framework project to avoid upgrade issues.
    - Redesign application to workaround framework.
    CONS: Project is less maintainable as different functions use different methods.

    No good recommendation is possible without knowing more about the OP's resources and problems.
    - Can Hibernate be fixed to handle the new requirements?
    - Is the Hibernate team already working to add these abilities?
    - Can new functionality use JDBC directly without interfering with the existing code?
    I would not discard the proven working code until the new methods have been proven stable and maintaining two systems requires more effort than replacing one.

    --
    I spend my life entertaining my brain.
  136. From F.O.Stanley: by Anonymous Coward · · Score: 0

    "Any fool can make something complicated; It takes a genius to make something simple"

    - F. O. Stanly, co-creator of the Stanley Steamer

  137. You goofed - learn from the mistake by SpinyNorman · · Score: 1

    You shouldn't design something, let alone start to implement it, until you fully understand the requirements, both present and anticipated for the future.

    Anticipating future requirements comes from experience, and shouldn't be something you should rely on coming from your boss. The result of this anticipation (which eventually comes as second nature) is to deisgn flexibility in from the start, and to choose a modular decomposition that lends itself to the types on enhancement you see fit to allow for easily.

    Eventually of course your code base may be asked to do something beyond the level of flexibility you've designed in, at which point you will need to rebase/redesign and refactor the code into something that can grow further. Failure to periodically refactor to maintain a clean design will result in the eventual death of the code base due to the 2nd law of thermodynamics.

  138. CODE FREELY by Anonymous Coward · · Score: 0

    I like coding my own stuff.
    It is easier to to get a 100% requirements, rather than 40-60% if you are lucky.

  139. so do you by Just6979 · · Score: 1

    the "my" is obviously a typo. the incorrect use of "peddling" (selling) instead of "pedaling" (pedal a bike using the pedals) is a genuine error of grammar (or vocabulary, IANALinguist [though i'd like to go back to school for it])

    --
    --Justin
    1. Re:so do you by mdielmann · · Score: 1

      Both are valid grammar errors, neither or which would be caught by a spell checker. How they came to be were likely different.

      --
      Sure I'm paranoid, but am I paranoid enough?
  140. Re:Reuse good code as much as possible by ClosedSource · · Score: 1

    Underwriters Laboratories http://www.ul.com/ulprodcert.html

  141. Re:Reuse good code as much as possible by loxosceles · · Score: 2, Funny

    Code better than PEAR?
    PHP's unsuitable
    But knowing that, safe.

  142. frameworks by Anonymous Coward · · Score: 0

    Frameworks solve the easy problems in new and unique ways. why? mgrs hope to hire flunkies in india and somehow the framework will magically make them productive. Also, its more fun to write a framework than to solve real problems and create a reusable library. Also because "architects" want to use somethign nobody else knows so they can feel important. That's frameworks in a nutshell. Great stuff for people who don't know what they are doing. Real boat anchors for those who do. When BEA starts talking about "Managed Servers" and other wordopedia those with real degrees feel like slapping the "architect" and pointing out Java cannot use over 3G user so has to have multiple processes running to immitate the big leagues. If you think spring is bad, trying throwing in Struts 1.x, Tiles, migrating to Struts 2 which is not and upgrade from Struts 1 but a rewrite, an outdated framework from Accenture called Grounds, various outdated frameworks from "platform" teams of people who no longer work for the company, and everything else. It takes 10x to 100x more manpower to use a good handfull of frameworks in your project than to just know what you're doing in the first place. BTW, I'll get your problem in Spring is the join problem. OR mappers never handle more than one table well. that's why we use SQL! It allows Set Calculus. Unless your OR mapper somehow helps with Set Calculus, then it really just gets in the way. Besides, doesn't everyone know how to write SQL by now!

  143. Re:Reuse good code as much as possible by TechnicalPenguin · · Score: 1

    It's worth mentioning, if you're going to use other peoples code, always wrap it up and call the wrapper rather than tightly coupling your own code to the foreign code. You never know when you'll want to replace it. The Bridge, Facade and Strategy design patterns are good for this sort of thing.

    I don't know that I would go so far as to say always. It depends on the source of the code (standard vs. non-standard, known vs. unknown, stable vs. unstable) and the likelihood that it might need to be replaced, someday, in the future. If it's never replaced, that extra abstraction layer is a complete waste of time and resources. Either way, it adds an extra layer of complexity, more code to test and debug, more time to write and maintain that code, and might even impact the overall performance, functionality, and maintainability of your code. All of that needs to be balanced against the chance that this extra work now will save you or someone else extra effort in the future.

    Overall, I believe in writing the code you need today and refactoring it when you need to change it tomorrow, because, in my experience, the changes I anticipated yesterday rarely match up with the changes that are actually needed today.

  144. FP ftw! by SL+Baur · · Score: 1

    I don't think I would call a form of programming that has been pretty-much the dominant form for nearly 20 years now

    In 1988, Ada was in its infancy and pretty much junk commercially. I wouldn't call any other OO language (or wanna-bes like Perl5) "dominant" until some years later and Ada was only dominant because it was mandated by the US DOD for all new software and they later backed down.

    When you have been around since practically the beginning of time (LISP was one of the first languages and is still around and thriving in various applications), then you can talk about not being a fad.

    Functional programming is a discipline (around greater than half a century and counting) and OO is a fad (around about 20 years, but only implemented in decent fashion a decade ago) in the same sense that the difference between a cult and a religion is that a cult is something you join, a religion is something you inherit from your parents.

    OB xkcd - http://xkcd.com/297/

  145. Right balance by kgish · · Score: 1

    Actually it's finding the right balance between reusing and rewriting code that makes a good developer worth his/her weight in gold!

  146. Big ominous frameworks are EVIL by Tablizer · · Score: 1

    I find that "helper" sub-frameworks to be more flexible than all-encompassing frameworks. If you date your abstractions instead of marry then, then it's easier to dump them for something better. Helper frameworks use a bunch of small functions or classes that work together by convention, not forced. You can skip or rewrite the parts as needed. And they are not over-filled with features in order to keep them simple.

    If you need a specific feature that's not there, you add it for that particular project and only borrow it down the road if another project matches that custom need. You don't keep collecting features as you go unless they are actually commonly needed in your org. This way your library doesn't get bloated.