- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
Yes, as I read it this is more of a "blame" scenario.
This dev team probably has little or no control over package distribution/delivery, and this is how they identify who sent what to where and when.
Admin
TRWTF is not using reflection.
Admin
WTF?????
Admin
but, but, build version changes precisely every time I compile a program, which keeps the build-to-change ratio at 1:1 level, so there is no benefit in separating the two. It's not like with the hardcoded host IP example where the ratio was more like 1:X :))
Admin
I guess everyone missed the part where it says the code does not compile until this file has been generated, and also the copy-pasting of the GenerateTagFile.java in all projects.
Admin
Admin
Are there better ways to do it? Sure. But my standards for deciding if code is screwed up are:
Does it work? This looks like it should. Pass.
Is it reasonably understandable by other programmers? Looks like. Pass.
Is it easy to maintain? Yes. Pass.
Is it efficient? Not the best, but shouldn't be awful. Pass, maybe with some minor reservations.
Is it robust, i.e. unlikely to fail? Might be some grounds for criticism here. Depending on how the build scripts are written, maybe a failed build would end up being mislabeled, and that could interfere with problem resolution. Maybe.
Admin
Admin
2. Is it reasonably understandable by other programmers? Not really. I mean, who expects that sort of thing? See also #5.
3. Is it easy to maintain? No! Fail! The "code generator" file and the associated build steps need to be copied to every project that uses that mechanism.
Overall I rate this as mild or head-scratcher on the WTF scale.
Admin
Yeah I also like the ones that are questionably wtf-worthy. Mostly because I like reading the best practice discussion. I come to this site to possibly get a laugh and possibly learn something.
CAPTCHA: ideo - a male idea
Admin
The compromise I'd recommend is to have the automatic build system include relevant information including date in the targets that are build. However there then need to be a way to manually override the strings when you want to do a historic build and have an exact match. By default builds made outside of the automatic build system should be clearly labelled in a way that can distinguish development builds from release builds.
Reproducible builds are good for certain validation of builds. For example you can have two different people look at the source being build and have both confirm that those executables are really build from that source.
Admin
I was thinking the same thing and that perhaps TRWTF was that the code wouldn't compile in this instance because it required the file that it would generate, if it successfully compiled. The workaround was a copy paste from elsewhere.
Admin
That's nothing. Wait until you meet GenerateGenerateTagFile.java
Admin
I can't claim to be an expert, but advice like version information lives in a non-executable file. If you want code modules that read that file for ease of use sounds like exactly the wrong thing to do to me.
Admin
Doesn't seem like much of a WTF to me.
For the naysayers what is the "correct" way to achieve this? I am genuinely curious.
In .NET land I update AssemblyInfo.cs and the wix installer xml files on the build server using NANT before compilation.
It's virtually the same thing.
Admin
I don't think I can parse that.
Admin
Admin
Admin
2. Is it reasonably understandable by other programmers? Not really. I mean, who expects that sort of thing? The fact that it is unexpected is not automatically an obstacle to understanding.
3. Is it easy to maintain? Yes, but you must take some steps to ensure it is reliably easy to maintain. You have to first realise that the tag file generator is part of the build system, not part of the body of source code, and should be deployed and launched as such. The rest more or less follows from there.
Oh, and remember Steve The Cynic's rule:
90%[1] of what we do as programmers is communicating with other people.
[1] It might not be exactly 90%, but the fraction is nevertheless close to 100%.
We do this through email, talking, the source code, and even documentation. In the context of this discussion, STCrule means that we should have documents that describe all this. But that's another battle to fight.
Admin
Our build process here generates a timstamp file that has the date, time and level information in the filename. The file is automatically included in the META-INF directory of every JAR, WAR or EAR file that is generated. That way, I can use 'jar' or 'zip' to get the version information from the command line, without first extracting a MANIFEST.MF and then looking at its content. Of course that is not the best solution if you want a '"-version" switch that prints the information, because then you'd want to know the filename in advance. For that, I'd probably prefer the MANIFEST.MF solution.
(captcha: dolor - oh these pains...)
Admin
I wrote a utility that will read in a hex file and it's matching .elf file, then update the hexfile with list of symbols and strings, then write it out into a ./images directory. The modified hexfiles get checked in with the code. That allows you to add compile dates, revision numbers, and checksums without modifying source files and recompiling. One key thing is it does not reformat the hexfile, so you can use diff, to verify changes.
Admin
I don't know what your problem is, but I understood it easily. The biggest barrier to my understanding was that I was constantly looking for the WTF, but I never found it.
This is intentional. The code generator and associated steps are part of the project so that they do not result in an additional external dependency. You would explicitly customize it for each project as the project demands.
Remember, the point of code re-use is to reduce work. Sometimes copying and making local mods really is better than using a library.
Admin
I agree it's not an ideal solution, but I think the benefits of making the repository much more of a "one-stop-shop" for what you need to build makes it worth it. As with every rule (probably including this one :-)) there are no completely hard and fast rules.
Admin
"Brian’s brain break" broke my brain.
Admin
I'm confused: Why is a two-stage process even needed? Why does the build process not just build the TagFile class, instead of building a TagFileBuilder class which is then run to build the TagFile class? After all, to build the former, the build process had to have all the information needed to build the latter, the way it's building it.
My brain hurt.
I'm reminded of those nested Russian dolls. Does he need a builder to build the builder of the builder of the tag file? Hmmmm....
Admin
Y'know, I actually think that's pretty cool.
Admin
Properties files can be easily changed by humans.
I'm guessing the point of this somewhat hacky build process is to have trustable build information available to the program at run time. Perhaps for some reporting and debugging purpose.
I highly doubt your operating system's build information is stored in text somewhere.
Either way, it's an eyebrow raiser at best, not a wtf.
Admin
I agree that checking build-generated files into source code is a bad idea. But that's not what this article expresses. It expresses that generating code at build time is a bad idea without any context around the reason why.
If a requirement was runtime availability of the build-time information that could not be easily modified by a malicious end-user, how would you accomplish it?
You're going to say "you can use a hex editor on compiled classes anyway" or something like that, but that's outside of my definition of "easily".
Admin
Good job trying to reinvent XML.
Admin
The javac compiler lacks a preprocessor, sure, but one could easily be added to the build scripts or other parts of the system if needed. For example, the following code works with CVS:
When CVS handles the file, it automatically fills that with the correct revision (and updates it again later). A similar system would be very easy to create and use with for example Ant scripts.
Admin
cough oracle enterprise manager cough
Admin
This kind of thing is practically encouraged in the .NET stack, although usually at design time rather than build time: T4 Templates.
Admin
Oh boy, another file to keep up with during install.