• (cs) in reply to Pjoterffies
    Pjoterffies:
    Severity One:
    portablejim:
    Is there really a difference when you are selecting 2 of 2 fields? Is it so you don't have to look up somewhere else the fields you are returning? Other reasons?
    You're assuming that the database table structure is immutable and that no DBA or other developer decides to add, say, 100 columns. If you don't need all columns, don't select all columns, because they're all sent over the network and increase the load on the network, the database server and the client application.

    Also, if you do 'select *' and then get rows 1 and 2, and somebody modifies the table structure and inserts a field between what used to be rows 1 and 2, your application ceases functioning. (Pre-empting another common mistake here.)

    'select *' is a sign of laziness. And whilst certain kinds of laziness are good assets for a developer (spending a week to write a program that will save you 10 minutes on each new project that you start), other kinds of laziness are liabilities (doing something the easy way because you couldn't be bothered to do it the proper way, like copy-and-paste code).

    There is a difference between laziness and foresight. Particularly in this context. What does the 10 minute saving achieve? It probably doesn't mean the dev goes home early, but rather that he starts other work 10 minutes sooner.

    Also, for the politically correct: I'm not lazy, I'm just energy efficient.

    There is also a difference between laziness, foresight and an appreciation of ROI. 10 mins = 6 projects per hour x 8 hours per day x 5 days per week = 240 projects to recoup cost (time). Personally that's more development projects than I've been involved with in the last 25 years. Sometimes it's just not worth bothering about.

  • Caeser Augustus (unregistered) in reply to Childish
    Childish:
    hoodaticus:
    JiP:
    imgx64:
    TRWTF is the base-12 calendar, obviously. We should move to the decimal system.
    Actually, Napoleon tried something like that once. 10 hour days, 10 minute hours, 10 second minutes. Sadly, the masses rejected this unifyingly brillant concept and it didn't catch on.

    Why don't we actually move to a hexadecimal system?

    For that matter, why don't we move to a unary date system and count the hash marks since Genesis Chapter 1?

    Actually, I think the Romans meant to have a 10 month calendar. Look at the Latin names:

    September :- sept=7 October :- octo=8 November :- nova=9 December :- deca=10

    The Moon just circles the Earth too many times in a year.

    I'll assume you are not a troll, though it's hard to say....

    I think those names derive more from the fact that the first three months of the year used to vary (Smarch (not rally, but couldn't resist - Mercedonius really) was occasionally included as a leap month after a varying length February), so the "real months" started from March (which then becomes month 1). Interestingly, this system takes a similar approach and requires March to be the first valid month....

  • Someone (unregistered) in reply to corwin766

    [quote user="corwin766"][quote user="C-Octothorpe"][quote user="lesle"][quote user="QJo"][quote user="GalacticCowboy"] Then there was the place where our username used to be our first name (or diminutive) concatenated with the first letter or our surname. Yes, Chris T had an attitude problem.[/quote]

    The government agency Miguel Orona worked for was first initial, last name. The poor guy was known (true) as morona.[/quote]I'd hate to have the name Maurice O'Lester...[/quote] I was at one place with the rule. Worked with an African American named Alan Ryan. [/quote] I find it a little disturbing that a priest by the name of Bernard Angus decide to use a similar naming mechanism for his email....

    Somehow, a church bulletin with bangus@some_isp.com as the contact seems a little inappropriate.

  • Dude (unregistered) in reply to LoztInSpace
    LoztInSpace:
    Pjoterffies:
    Severity One:
    portablejim:
    Is there really a difference when you are selecting 2 of 2 fields? Is it so you don't have to look up somewhere else the fields you are returning? Other reasons?
    You're assuming that the database table structure is immutable and that no DBA or other developer decides to add, say, 100 columns. If you don't need all columns, don't select all columns, because they're all sent over the network and increase the load on the network, the database server and the client application.

    Also, if you do 'select *' and then get rows 1 and 2, and somebody modifies the table structure and inserts a field between what used to be rows 1 and 2, your application ceases functioning. (Pre-empting another common mistake here.)

    'select *' is a sign of laziness. And whilst certain kinds of laziness are good assets for a developer (spending a week to write a program that will save you 10 minutes on each new project that you start), other kinds of laziness are liabilities (doing something the easy way because you couldn't be bothered to do it the proper way, like copy-and-paste code).

    There is a difference between laziness and foresight. Particularly in this context. What does the 10 minute saving achieve? It probably doesn't mean the dev goes home early, but rather that he starts other work 10 minutes sooner.

    Also, for the politically correct: I'm not lazy, I'm just energy efficient.

    There is also a difference between laziness, foresight and an appreciation of ROI. 10 mins = 6 projects per hour x 8 hours per day x 5 days per week = 240 projects to recoup cost (time). Personally that's more development projects than I've been involved with in the last 25 years. Sometimes it's just not worth bothering about.
    Ya, but I think "week", "10 minutes" and "per project" were arbitrary quantities rather than well thought out, realistic measures....what he means is sometimes up front effort is worth longer term savings

  • Nebs (unregistered) in reply to dguthurts
    dguthurts:
    portablejim:
    I am an inexperienced programmer, an so I use the CodeSODs to identify the problems with the code and write something better (someone normally posts a better solution somewhere in the comments).

    I would do it with:

    • DATE instead of VARCHAR
    • SELECT <explicit list of fields> FROM DataTable ORDER BY yearmonth DESC LIMIT 3

    <personal_achievement> nearly first </personal_achievement>

    FTFY

    FTFY ;-)

  • Nebs (unregistered)

    ... And btw having an explicit list of fields in this instance is more trouble than it's worth, if nothing else in terms of maintainability.

    Lost count of the number of times explicit lists have caused headaches when a select * would have been much better.

  • (cs) in reply to boog
    boog:
    You'd think so, yes. But I have also run into the type of programmers that believe the STATE column needs to be VARCHAR(3) to allow for null-terminators.
    No, no, STATE needs to be VARCHAR(3) to allow for New South Wales, Queensland, Victoria and the Australian Capital Territory.

    Of course ours is VARCHAR(15) so we can fit 'Unspecified' in there.

  • (cs) in reply to Scarlet Manuka
    Scarlet Manuka:
    No, no, STATE needs to be VARCHAR(3) to allow for New South Wales, Queensland, Victoria and the Australian Capital Territory.

    Of course ours is VARCHAR(15) so we can fit 'Unspecified' in there.

    I'd have thought you'd go for VARCHAR(30) or so, so you can fit in “Australian Capital Territory” (28 characters by my count).

  • Tobias (unregistered)

    As the movie Hackers told us, one of the most popular passwords is god. So maybe someone should try it.

  • QJo (unregistered) in reply to boog
    boog:
    QJo:
    GalacticCowboy:
    Obviously, his name was "Gregory Oliver Davis" (or something like that) and they named everything with initials.

    Could have been called Godfrey.

    Then there was the place where our username used to be our first name (or diminutive) concatenated with the first letter or our surname. Yes, Chris T had an attitude problem.

    I can't imagine what he had to be upset about. I bet Takeshi Takeda got way more junk mail.

    +300 Cried laughing.

  • QJo (unregistered) in reply to Father Time
    Father Time:
    10 is handy because we have learnt to adapt it easily to allow fractions to be represented nicely, but it is not necessarily the best numbering system for all purposes.

    10 is no more handy than any other number base from that perspective. You can express fractions using a base-radix system (which is what I presume you're referring to) in any number at all (as long as it's greater than 1).

    In fact there's no mathematical limitation to integers, or even rationals, or even reals. According to this: http://en.wikipedia.org/wiki/Complex_base_systems ... a number base can even be complex.

  • QJo (unregistered) in reply to LoztInSpace
    LoztInSpace:
    Pjoterffies:
    Severity One:
    portablejim:
    Is there really a difference when you are selecting 2 of 2 fields? Is it so you don't have to look up somewhere else the fields you are returning? Other reasons?
    You're assuming that the database table structure is immutable and that no DBA or other developer decides to add, say, 100 columns. If you don't need all columns, don't select all columns, because they're all sent over the network and increase the load on the network, the database server and the client application.

    Also, if you do 'select *' and then get rows 1 and 2, and somebody modifies the table structure and inserts a field between what used to be rows 1 and 2, your application ceases functioning. (Pre-empting another common mistake here.)

    'select *' is a sign of laziness. And whilst certain kinds of laziness are good assets for a developer (spending a week to write a program that will save you 10 minutes on each new project that you start), other kinds of laziness are liabilities (doing something the easy way because you couldn't be bothered to do it the proper way, like copy-and-paste code).

    There is a difference between laziness and foresight. Particularly in this context. What does the 10 minute saving achieve? It probably doesn't mean the dev goes home early, but rather that he starts other work 10 minutes sooner.

    Also, for the politically correct: I'm not lazy, I'm just energy efficient.

    There is also a difference between laziness, foresight and an appreciation of ROI. 10 mins = 6 projects per hour x 8 hours per day x 5 days per week = 240 projects to recoup cost (time). Personally that's more development projects than I've been involved with in the last 25 years. Sometimes it's just not worth bothering about.

    On the other hand, maybe the extra time spent also results in a design paradigm that produces more reliable and/or efficient code. In which case not only is the code going to run quicker and/or less resource-intensively, but you are saving a hitherto unmeasured quantity of time spent bugfixing.

  • The Poop... of DOOM (unregistered) in reply to douglas
    douglas:
    QJo:
    Somebody remind me of the psychological phenomenon that stupid people are too stupid to know how stupid they are, while wiser people are clever enough to know they're not really all that clever. Therefore people who think they're as clever as "god" must be the stupidest people in the world.
    There are the people too stupid to recognize their own stupidity, and the people smart enough to realize they're not really all that incredible. And then there are the people that really are ridiculously smart and know it.

    So, if someone says he's as clever as god, all that really tells you is that he's not in the middle. He could just be stupid, or he really could be that smart.

    Then again, stupidity is more common than that degree of intelligence, so it's not a bad assumption that a supposed "god" is probably stupid.

    Two things:

    1. There's another type. It's the type that knows they're only average, but mock by saying they're oh so great and never ever have a bug and are god programmers, all with a huge grin on their face while seeping through a whole ooze of sarcasm. (I'm quite guilty of that, btw. Although I don't know if they caught on to the sarcasm...)

    2. Those that really are that smart and good at their programming language, tend to stay silent about it, so they can work on their projects instead of having to deal with the hordes of people who'll go: "Oh I had an idea can you make it for me" and then bug them all evening 'bout it, and the day after, and then forget all about it. That crap's good for the wannabes and for the beginners to get some experience. I think as soon as you become an average programmer, you'll sigh and try to get away from that. For really good ones, it'd be even more frustrating. Hence them probably not boasting their skills.

  • The Poop... of DOOM (unregistered) in reply to dohpaz42
    dohpaz42:
    The Poop... of DOOM:
    I'd go with a timestamp instead of a Date, but that's just my personal preference. I'm just more comfortable with PHP's timestamp handling than with its date handling. Plus, there's also something reassuring about just pulling an int in from the DB, instead of some object.
    </facepalm>

    Man are you ill-informed. The TIMESTAMP and DATETIME field types are stored using the same 'YYYY-MM-DD HH:MM:SS' format. There are two differences between them: 1) TIMESTAMPs are stored in UTC, but retrieved in the server's current timezone, and 2) TIMESTAMP has the 'ON UPDATE CURRENT_TIMESTAMP' event.

    That said, if you really wanted to make your life more difficult, you would store integer times as UNSIGNED INT (or BIGINT, depending on how far into the future you wanted to store times). But, doing so would require convoluting your SQL queries to do date/time comparisons:

    SELECT * 
    FROM myTable 
    WHERE DATE_FORMAT(myIntTimestamp, "%Y-%m-%d %H:%i%s") < NOW();

    And that's just a simple example! Start throwing in the logic to compare months, years and days; with some DATE_ADD/DATE_SUB and whatever other business logic that you need, and you're just asking for a front-page WTF.

    The right tool for the right job.

    PS. You really should RTFM:

    TIMESTAMP DATETIME

    Thanks for explaining that. I actually didn't know that. I tend to just pull the timestamp in as an int and do the processing in the logic, and was never fond of using DATE, since I've seen too many people fumble about and bang their heads against the wall trying to get it to work. But if they were just crap and DATE's actually easier to use than pulling in an int and processing it in the code instead of the query, then so much the better, as it'll make my code that bit cleaner.

  • The Poop... of DOOM (unregistered) in reply to Tobias
    Tobias:
    As the movie Hackers told us, one of the most popular passwords is god. So maybe someone should try it.
    Yeah, cause, although the password "penis" is always too short, the password "god" isn't :D
  • reductio ad ridiculum (unregistered) in reply to QJo
    QJo:
    LoztInSpace:
    Pjoterffies:
    Severity One:
    portablejim:
    Is there really a difference when you are selecting 2 of 2 fields? Is it so you don't have to look up somewhere else the fields you are returning? Other reasons?
    You're assuming that the database table structure is immutable and that no DBA or other developer decides to add, say, 100 columns. If you don't need all columns, don't select all columns, because they're all sent over the network and increase the load on the network, the database server and the client application.

    Also, if you do 'select *' and then get rows 1 and 2, and somebody modifies the table structure and inserts a field between what used to be rows 1 and 2, your application ceases functioning. (Pre-empting another common mistake here.)

    'select *' is a sign of laziness. And whilst certain kinds of laziness are good assets for a developer (spending a week to write a program that will save you 10 minutes on each new project that you start), other kinds of laziness are liabilities (doing something the easy way because you couldn't be bothered to do it the proper way, like copy-and-paste code).

    There is a difference between laziness and foresight. Particularly in this context. What does the 10 minute saving achieve? It probably doesn't mean the dev goes home early, but rather that he starts other work 10 minutes sooner.

    Also, for the politically correct: I'm not lazy, I'm just energy efficient.

    There is also a difference between laziness, foresight and an appreciation of ROI. 10 mins = 6 projects per hour x 8 hours per day x 5 days per week = 240 projects to recoup cost (time). Personally that's more development projects than I've been involved with in the last 25 years. Sometimes it's just not worth bothering about.

    On the other hand, maybe the extra time spent also results in a design paradigm that produces more reliable and/or efficient code. In which case not only is the code going to run quicker and/or less resource-intensively, but you are saving a hitherto unmeasured quantity of time spent bugfixing.

    I was going to jump on the bad estimate bandwagon, then found it had been well covered. I too knew what he meant, and my only concern was that occasionally managers hit this site, and they sometimes know arithmetic. I didn't want them getting the wrong idea.

    rar

  • QJo (unregistered) in reply to reductio ad ridiculum
    reductio ad ridiculum:
    QJo:
    LoztInSpace:
    Pjoterffies:
    Severity One:
    portablejim:
    Is there really a difference when you are selecting 2 of 2 fields? Is it so you don't have to look up somewhere else the fields you are returning? Other reasons?
    You're assuming that the database table structure is immutable and that no DBA or other developer decides to add, say, 100 columns. If you don't need all columns, don't select all columns, because they're all sent over the network and increase the load on the network, the database server and the client application.

    Also, if you do 'select *' and then get rows 1 and 2, and somebody modifies the table structure and inserts a field between what used to be rows 1 and 2, your application ceases functioning. (Pre-empting another common mistake here.)

    'select *' is a sign of laziness. And whilst certain kinds of laziness are good assets for a developer (spending a week to write a program that will save you 10 minutes on each new project that you start), other kinds of laziness are liabilities (doing something the easy way because you couldn't be bothered to do it the proper way, like copy-and-paste code).

    There is a difference between laziness and foresight. Particularly in this context. What does the 10 minute saving achieve? It probably doesn't mean the dev goes home early, but rather that he starts other work 10 minutes sooner.

    Also, for the politically correct: I'm not lazy, I'm just energy efficient.

    There is also a difference between laziness, foresight and an appreciation of ROI. 10 mins = 6 projects per hour x 8 hours per day x 5 days per week = 240 projects to recoup cost (time). Personally that's more development projects than I've been involved with in the last 25 years. Sometimes it's just not worth bothering about.

    On the other hand, maybe the extra time spent also results in a design paradigm that produces more reliable and/or efficient code. In which case not only is the code going to run quicker and/or less resource-intensively, but you are saving a hitherto unmeasured quantity of time spent bugfixing.

    I was going to jump on the bad estimate bandwagon, then found it had been well covered. I too knew what he meant, and my only concern was that occasionally managers hit this site, and they sometimes know arithmetic. I didn't want them getting the wrong idea.

    rar

    To put it another way: I would rather spend an extra day or so up front so as to save me half an hour further down the line. Because that half an hour down the line is usually vitally more valuable.

    Simple things like adding error trapping to your build scripts, making sure your error messages interpret the error codes into English, parameterising those magic numbers you know you're never going to want to change ever, and so on.

    Oh, and it goes without saying you set up the infrastructure to implement your unit tests before you started, doesn't it?

    I've found that when "engineers" explain that they haven't got the time to do this boring stuff at project start, what they mean is they haven't got the patience, because they can't wait to get cracking on the exciting code cutting. To which I say, forget the code cutting, I'm going to embark on an exercise in staff cutting.

  • (cs)

    Ah, it looks like my comment sparked a (small) discussion.

    Indeed, the numbers I mentioned were arbitrary, and even a bit ironic. But I did have a specific example in mind.

    At work, we do everything in Java, and some years ago, it was decided to have web services to be self-contained, meaning that they should be using javax.xml.ws.Endpoint (introduced in JAX-WS 2.0) instead of Tomcat to run them.

    But this would mean having to modify the build.xml file for each project for each developer, so that a .jar file would be generated in addition to a .war file, and a whole lot of things that are just dumb and error-prone.

    So, I decided to write a little application that loads a .war file, looks for the web services, and starts all of them as endpoints.

    The trickiest part was actually to write a class loader that is both efficient and loads classes and resources from a .jar file inside of a .war file, inside of a .ear file if necessary.

    (Truth be told, my attempts to introduce some sort of caching led to strange class loading errors that aren't very easy to solve in a reasonable amount of time. Now, with Java 7's NIO libraries, I intend to rewrite the archive class loader.)

    And guess what? It's become a critical application. The support people love it, because it's light-weight and uses all of our standard libraries for configuration and such, and the developers love it because they can run their web services on both Tomcat (to test) and on ws-run, without any modifications.

    Call it laziness or foresight, but in this case it was a success, even though the initial outset was that I didn't want to do a lot of boilerplate code for each project.

  • QJo (unregistered) in reply to Severity One
    Severity One:
    Ah, it looks like my comment sparked a (small) discussion.

    Indeed, the numbers I mentioned were arbitrary, and even a bit ironic. But I did have a specific example in mind.

    At work, we do everything in Java, and some years ago, it was decided to have web services to be self-contained, meaning that they should be using javax.xml.ws.Endpoint (introduced in JAX-WS 2.0) instead of Tomcat to run them.

    But this would mean having to modify the build.xml file for each project for each developer, so that a .jar file would be generated in addition to a .war file, and a whole lot of things that are just dumb and error-prone.

    So, I decided to write a little application that loads a .war file, looks for the web services, and starts all of them as endpoints.

    The trickiest part was actually to write a class loader that is both efficient and loads classes and resources from a .jar file inside of a .war file, inside of a .ear file if necessary.

    (Truth be told, my attempts to introduce some sort of caching led to strange class loading errors that aren't very easy to solve in a reasonable amount of time. Now, with Java 7's NIO libraries, I intend to rewrite the archive class loader.)

    And guess what? It's become a critical application. The support people love it, because it's light-weight and uses all of our standard libraries for configuration and such, and the developers love it because they can run their web services on both Tomcat (to test) and on ws-run, without any modifications.

    Call it laziness or foresight, but in this case it was a success, even though the initial outset was that I didn't want to do a lot of boilerplate code for each project.

    +1 There's so many levels of win here.

  • WthyrBendragon (unregistered)

    That man is a legend

    in his own mind.

  • (cs) in reply to reductio ad ridiculum
    reductio ad ridiculum:
    QJo:
    LoztInSpace:
    Pjoterffies:
    Severity One:
    portablejim:
    Is there really a difference when you are selecting 2 of 2 fields? Is it so you don't have to look up somewhere else the fields you are returning? Other reasons?
    You're assuming that the database table structure is immutable and that no DBA or other developer decides to add, say, 100 columns. If you don't need all columns, don't select all columns, because they're all sent over the network and increase the load on the network, the database server and the client application.

    Also, if you do 'select *' and then get rows 1 and 2, and somebody modifies the table structure and inserts a field between what used to be rows 1 and 2, your application ceases functioning. (Pre-empting another common mistake here.)

    'select *' is a sign of laziness. And whilst certain kinds of laziness are good assets for a developer (spending a week to write a program that will save you 10 minutes on each new project that you start), other kinds of laziness are liabilities (doing something the easy way because you couldn't be bothered to do it the proper way, like copy-and-paste code).

    There is a difference between laziness and foresight. Particularly in this context. What does the 10 minute saving achieve? It probably doesn't mean the dev goes home early, but rather that he starts other work 10 minutes sooner.

    Also, for the politically correct: I'm not lazy, I'm just energy efficient.

    There is also a difference between laziness, foresight and an appreciation of ROI. 10 mins = 6 projects per hour x 8 hours per day x 5 days per week = 240 projects to recoup cost (time). Personally that's more development projects than I've been involved with in the last 25 years. Sometimes it's just not worth bothering about.

    On the other hand, maybe the extra time spent also results in a design paradigm that produces more reliable and/or efficient code. In which case not only is the code going to run quicker and/or less resource-intensively, but you are saving a hitherto unmeasured quantity of time spent bugfixing.

    I was going to jump on the bad estimate bandwagon, then found it had been well covered. I too knew what he meant, and my only concern was that occasionally managers hit this site, and they sometimes know arithmetic. I didn't want them getting the wrong idea.

    rar

    Ah come on. The original was quite clear and quite specific. A week dev to save 10 minutes per new project. Manager or not, if he really meant something like what Pjoterffies or indeed his second post wrote then that's a pretty shocking communication of ideas. I'd say I was fairly justified in interpreting it as "spending a week to write a program that will save you 10 minutes on each new project that you start".

  • Level 2 (unregistered) in reply to Dude
    LoztInSpace:
    Pjoterffies:
    Severity One:
    portablejim:
    Is there really a difference when you are selecting 2 of 2 fields? Is it so you don't have to look up somewhere else the fields you are returning? Other reasons?
    You're assuming that the database table structure is immutable and that no DBA or other developer decides to add, say, 100 columns. If you don't need all columns, don't select all columns, because they're all sent over the network and increase the load on the network, the database server and the client application.

    Also, if you do 'select *' and then get rows 1 and 2, and somebody modifies the table structure and inserts a field between what used to be rows 1 and 2, your application ceases functioning. (Pre-empting another common mistake here.)

    'select *' is a sign of laziness. And whilst certain kinds of laziness are good assets for a developer (spending a week to write a program that will save you 10 minutes on each new project that you start), other kinds of laziness are liabilities (doing something the easy way because you couldn't be bothered to do it the proper way, like copy-and-paste code).

    There is a difference between laziness and foresight. Particularly in this context. What does the 10 minute saving achieve? It probably doesn't mean the dev goes home early, but rather that he starts other work 10 minutes sooner.

    Also, for the politically correct: I'm not lazy, I'm just energy efficient.

    There is also a difference between laziness, foresight and an appreciation of ROI. 10 mins = 6 projects per hour x 8 hours per day x 5 days per week = 240 projects to recoup cost (time). Personally that's more development projects than I've been involved with in the last 25 years. Sometimes it's just not worth bothering about.
    But it was more fun than real work

  • (cs) in reply to LoztInSpace
    LoztInSpace:
    Ah come on. The original was quite clear and quite specific. A week dev to save 10 minutes per new project. Manager or not, if he really meant something like what Pjoterffies or indeed his second post wrote then that's a pretty shocking communication of ideas. I'd say I was fairly justified in interpreting it as "spending a week to write a program that will save you 10 minutes on each new project that you start".
    True, but irony very easily gets lost using a text-only medium, and I doubt that anybody picked it up.

    Read my explanation a couple of postings above; it should become clearer how spending a week (more or less; all in all, we probably spent more time on it than just a week by now) can help several teams across the entire organisation, in a way that is very hard to quantify in time saved. It's more than just the 10 minutes per project; it's also the elimination of a potential source of mistakes, and a simplification of a couple of other processes.

  • (cs) in reply to moxy
    moxy:
    Now I eat humble pie.

    How's Queen Lisa been?

    P.S. now I have that song stuck in my head and I hate you :)

  • Nickster (unregistered) in reply to Moxy
    Once, I was the King of Spain.

    Ha! Now you work at the Pizza Pizza.

  • (cs) in reply to Severity One
    Severity One:
    [snip] So, I decided to write a little application that loads a .war file, looks for the web services, and starts all of them as endpoints.

    [snip]

    And guess what? It's become a critical application. The support people love it, because it's light-weight and uses all of our standard libraries for configuration and such, and the developers love it because they can run their web services on both Tomcat (to test) and on ws-run, without any modifications.

    Call it laziness or foresight, but in this case it was a success, even though the initial outset was that I didn't want to do a lot of boilerplate code for each project.

    I don't suppose this code/library is available outside your organization? We need something similar and it would be quite nice to not have to reinvent the wheel.

  • the beholder (unregistered) in reply to hes
    hes:
    not a panic, a con game, did you not make $, yen, pounds, bucks, rubles(sic) rubles, pesos, etc. waiting on the next one. was tried again with 2012 but not getting enough traction, especiall with the horrible move leading the charge.
    And no quack.
  • QJo (unregistered) in reply to LoztInSpace
    LoztInSpace:
    reductio ad ridiculum:
    QJo:
    LoztInSpace:
    Pjoterffies:
    Severity One:
    portablejim:
    Is there really a difference when you are selecting 2 of 2 fields? Is it so you don't have to look up somewhere else the fields you are returning? Other reasons?
    You're assuming that the database table structure is immutable and that no DBA or other developer decides to add, say, 100 columns. If you don't need all columns, don't select all columns, because they're all sent over the network and increase the load on the network, the database server and the client application.

    Also, if you do 'select *' and then get rows 1 and 2, and somebody modifies the table structure and inserts a field between what used to be rows 1 and 2, your application ceases functioning. (Pre-empting another common mistake here.)

    'select *' is a sign of laziness. And whilst certain kinds of laziness are good assets for a developer (spending a week to write a program that will save you 10 minutes on each new project that you start), other kinds of laziness are liabilities (doing something the easy way because you couldn't be bothered to do it the proper way, like copy-and-paste code).

    There is a difference between laziness and foresight. Particularly in this context. What does the 10 minute saving achieve? It probably doesn't mean the dev goes home early, but rather that he starts other work 10 minutes sooner.

    Also, for the politically correct: I'm not lazy, I'm just energy efficient.

    There is also a difference between laziness, foresight and an appreciation of ROI. 10 mins = 6 projects per hour x 8 hours per day x 5 days per week = 240 projects to recoup cost (time). Personally that's more development projects than I've been involved with in the last 25 years. Sometimes it's just not worth bothering about.

    On the other hand, maybe the extra time spent also results in a design paradigm that produces more reliable and/or efficient code. In which case not only is the code going to run quicker and/or less resource-intensively, but you are saving a hitherto unmeasured quantity of time spent bugfixing.

    I was going to jump on the bad estimate bandwagon, then found it had been well covered. I too knew what he meant, and my only concern was that occasionally managers hit this site, and they sometimes know arithmetic. I didn't want them getting the wrong idea.

    rar

    Ah come on. The original was quite clear and quite specific. A week dev to save 10 minutes per new project. Manager or not, if he really meant something like what Pjoterffies or indeed his second post wrote then that's a pretty shocking communication of ideas. I'd say I was fairly justified in interpreting it as "spending a week to write a program that will save you 10 minutes on each new project that you start".

    This would be the sort of boss who would fire you for disobeying his short-sighted, bean-counting orders. Run for the hills from him and all his kind who don't trust the engineers to make their decisions, and who micromanages all the juice from everything they touch.

  • QJo (unregistered) in reply to zelmak
    zelmak:
    Severity One:
    [snip] So, I decided to write a little application that loads a .war file, looks for the web services, and starts all of them as endpoints.

    [snip]

    And guess what? It's become a critical application. The support people love it, because it's light-weight and uses all of our standard libraries for configuration and such, and the developers love it because they can run their web services on both Tomcat (to test) and on ws-run, without any modifications.

    Call it laziness or foresight, but in this case it was a success, even though the initial outset was that I didn't want to do a lot of boilerplate code for each project.

    I don't suppose this code/library is available outside your organization? We need something similar and it would be quite nice to not have to reinvent the wheel.

    Is this a variant on "Send me teh codez"?

  • Chuck (unregistered)

    Actually, this code will never work ever.

    Did anyone else notice the variable names are misspelled?

    $last_three_yearmonths = array();
    
    for ($i = (int) $yearmonth - 2 ; $i <= (int) $yearmonth; $i++) {
         $last_three_yearmonths[] = (string) $i; }
    
    $sql_three_last_yearmonths = "'".join("', '", $three_last_yearmonths)."'";
    

    $three_last_yearmonths doesn't exist. Oops.

  • (cs) in reply to QJo

    No, that would be

    I dnt suppze this codez is availalbe ousidez youre organation...{you get the idea}... reinventz teh wehelz.

  • The Poop... of DOOM (unregistered) in reply to Chuck
    Chuck:
    Actually, this code will never work ever.

    Did anyone else notice the variable names are misspelled?

    $last_three_yearmonths = array();
    
    for ($i = (int) $yearmonth - 2 ; $i <= (int) $yearmonth; $i++) {
         $last_three_yearmonths[] = (string) $i; }
    
    $sql_three_last_yearmonths = "'".join("', '", $three_last_yearmonths)."'";
    

    $three_last_yearmonths doesn't exist. Oops.

    I've seen similar in code I've got to maintain. The function got user ID passed on as uid (which is the common way of calling it in that framework). They then kept using iud. Their SQL query also was written horribly. It was supposed to pull the user's profile node from the nodes table. That nodes table is a reference list of all nodes + types + author. So what they had to do, is add a WHERE type = 'profile'. But noooooooo, just "SELECT * FROM nodes WHERE uid = %d" and then replacing %d with iud. The most surprising thing is that it took several maintainers and over a year before it got noticed. My fix: Took that whole function out and wrote it properly -- no misspellings, the proper query and no messing about for bugger-all afterwards.

  • (cs) in reply to The Poop... of DOOM
    The Poop... of DOOM:
    I've seen similar in code I've got to maintain. The function got user ID passed on as uid (which is the common way of calling it in that framework). They then kept using iud.
    But why would we be interested in an interface to the users' teeth?
  • JJ (unregistered)

    Ray, when someone asks you if you're a god, you say "YES"!

  • (cs) in reply to JJ
    JJ:
    Ray, when someone asks you if you're a god, you say "YES"!
    Good point. It could be that Lori's coworker had a bad run-in with PHP Gozer.
  • (cs)

    Courtesy of god mangling dates, today is still yesterday.

  • Jay (unregistered)

    It seems to me that most if not all of the people I've worked with who really were geniuses didn't go around telling everybody that they were geniuses. They just did brilliant things, and let everyone else say that they were geniuses.

    Maybe if you find it necessary to tell everyone that you're a genius, this is because no one can see it for themselves by looking at your work. They're all fooled into thinking it's very ordinary. I'm sure that you're convinced it's because they're all too stupid to recognize genius when they see it.

  • drobnox (unregistered) in reply to Moxy
    Moxy:
    golddog:
    King of such a small domain.

    Once, I was the King of Spain.

    I've never been to Spain, but I've been to Oklahoma.

  • Schol-R-LEA (unregistered)

    Perhaps he was simply taking Winston Zeddemore's advice... though why someone would ask that question is beyond me.

  • (cs) in reply to Matt Westwood
    Matt Westwood:
    lesle:
    QJo:
    GalacticCowboy:
    Obviously, his name was "Gregory Oliver Davis" (or something like that) and they named everything with initials.

    Could have been called Godfrey.

    Then there was the place where our username used to be our first name (or diminutive) concatenated with the first letter or our surname. Yes, Chris T had an attitude problem.

    The government agency Miguel Orona worked for was first initial, last name. The poor guy was known (true) as morona.

    A friend of mine had a client called Richard Head. "Oh, just call me Dick," he said, at their first meeting.

    I once worked with a guy named Rich Everhard. At one point, he did change his name...to "Everhardt".

    Never did understand why Rich chose to go through that trouble and not take care of the seemingly obvious problem.

  • Cheong (unregistered)

    I can reassure you that he is God, as only God can make a year has 99 months.

  • Cheong (unregistered) in reply to Cheong
    Cheong:
    I can reassure you that he is God, as only God can make a year has 99 months.
    My mistake. It should be 100 month per year, or it could work if His power can make 102 - 1 = 99... :P
  • GFK (unregistered) in reply to Cheong
    Cheong:
    Cheong:
    I can reassure you that he is God, as only God can make a year has 99 months.
    My mistake. It should be 100 month per year, or it could work if His power can make 102 - 1 = 99... :P

    It's ok, it's 100 months/year, because god uses 0-based indexes.

  • (cs) in reply to zelmak
    zelmak:
    Severity One:
    So, I decided to write a little application that loads a .war file, looks for the web services, and starts all of them as endpoints.
    I don't suppose this code/library is available outside your organization? We need something similar and it would be quite nice to not have to reinvent the wheel.
    No, sorry, we're an in-house shop and although personally I don't see much strategic value in it, it is the intellectual property of my employer. I'm one of the six remaining software developers in a company that has tens of thousands of employees world-wide, and hundreds of millions of customers, and I'd like to keep it that way. :)

    (Explanation: there are national companies all around, and all of them have outsourced their software development, except ours because our wages are low enough.)

    But nothing is stopping me from describing what the program does.

    Before I start, though, you have to make a choice, whether you want to do it the complex way and write a classloader that will load directly from a WAR file, or whether you're happy to just load from an unpacked WAR file. You save yourself a lot of trouble if you do it the latter way, but the former way is more elegant.

    First, find the schema of WEB-INF/sun-jaxws.xml. Use JAXB to create a class of that, saves you a bunch of XML parsing. Then, load that file, instantiate the JAXB object and invoke the 'getEndpoints().getEndpoint()' method on it, which returns a list of EndpointType objects.

    Find the class name of each web service (there may be more than one) with the getImplementation() method. Instantiate this class (you may need to load it before if you go down the classloader path with ClassLoader.loadClass), create its URL with the getURLPattern() method, create an endpoint with Endpoint.create(yourWebServiceClass) and publish it with endpoint.publish(yourWebServiceURL).

    If you want HTTPS, you'll have to do the bit with the key store, key manager factory, trust factory, SSL context, HttpsConfigurator and HttpsServer. Example code is easily found with Google - that's what we did. Instead of publishing the endpoint using the URL directly, you need to publish it on the context that you get when invoking the createContext(yourWebServiceURL.getPath()) method of the HttpsServer object.

    Now, the tool that we're using is obviously a bit more complex than that. For example, it has a logger that logs all XML requests using log4j. It also uses our standard configuration libraries, that load the configuration file(s) from an externally defined path and represent them as Java object - another one of those little libraries that make your life as a programmer a lot easier.

    Finally, it uses a library to run as some sort of service, so that startup and shutdown (using a ShutdownHook) are done in a standard way, logging is initialised, etc. Also, it installs a security manager so that a call to System.exit() does not shut down the program.

    If you have an idea what to do, it shouldn't take you more than a few days to write it, including testing. But this is a tool that will likely get extra functionality over time, so start with simple functionality, and take it from there.

  • EVIL US HACK0R!! (unregistered)

    TRWTFS TRWFSTS IS IMAGEMAGIC ISTNEAD OF IMAGEMAGICK WTF WTF!!!!

    CAPATCHAA!!! PECUS!!!

  • (cs)

    Blasphemy :D

  • (cs) in reply to Severity One
    Severity One:
    portablejim:
    Is there really a difference when you are selecting 2 of 2 fields? Is it so you don't have to look up somewhere else the fields you are returning? Other reasons?
    You're assuming that the database table structure is immutable and that no DBA or other developer decides to add, say, 100 columns. If you don't need all columns, don't select all columns, because they're all sent over the network and increase the load on the network, the database server and the client application.

    Also, if you do 'select *' and then get rows 1 and 2, and somebody modifies the table structure and inserts a field between what used to be rows 1 and 2, your application ceases functioning. (Pre-empting another common mistake here.)

    'select *' is a sign of laziness. And whilst certain kinds of laziness are good assets for a developer (spending a week to write a program that will save you 10 minutes on each new project that you start), other kinds of laziness are liabilities (doing something the easy way because you couldn't be bothered to do it the proper way, like copy-and-paste code).

    Is referring to columns as "rows", twice in one sentence, laziness? Probably not. After some thought, I knew what you meant.

    But you weren't careful! That kind of laziness can be a liability... And you couldn't be bothered to use the proper words... :-)

  • fritters (unregistered) in reply to Nickster
    Nickster:
    Once, I was the King of Spain.

    Ha! Now you work at the Pizza Pizza.

    Finally, people that get the reference!

  • Jeremy (unregistered)

    I bet he was using jpgraph. That's the simple way to deal with dates on the x-axis (after which you can shove in the correct values manually). The correct way requires a few more lines of code.

  • (cs) in reply to fritters

    Funny thing was that I had no idea Weird Al's King of Suede was a parody of King of Pain until someone posted on alt.music.moxy-fruvous - yes, it was back when USENET was a thing - their "adjustment" of the King of Spain lyrics to fit the King of Pain music.

    (FYI, King of Suede is one of the few Weird Al songs I actively can't stand. And I've been to see him in concert 27 times. I almost don't want to go to another one cause I want to hold onto that 27 lol)

Leave a comment on “God Date Mangling 101”

Log In or post as a guest

Replying to comment #:

« Return to Article