I'm Doing It Wrong
wellbredgrapefruit.com
wellbredgrapefruit.com
At least I can look at ideas I had 6 months ago and say now that that was a really stupid idea. Progress...
One of my fave WTFs was seeing a user profile table with 180 columns in it, one for each country - "is_us", "is_uk", "is_france", etc - with a y or n (or null) in each, and 180 hand-done queries in the login page to figure out what countries you lived in. I've never even come close to writing something that bad, but mostly because I'm lazy. Had that code even been in a loop, I'd have been less harsh on it.
Eventually, we discovered that it was actually P or N which stood for "positive or negative". It still didn't make much sense and needed to be renamed, but we got a good laugh out of it. I guess the original developer just didn't realize the association. The code was from India, so I'm sure English was not his first language.
No you don't.
Technical debt is like actual debt: It's bad to let it pile up, but it can give you powerful leverage. Don't quite know how to do something? Well, if you don't even know exactly what it is, it's going to be much harder to write it in an elegant way from the get-go! Write it so it works at all, then refactor your way out of stupid architecture.
I did this the other day, even though I already had an architecture designed, and what I came up with was even better than what I had thought of. The code will talk to you. There may well be CodeSmells. By playing with code, you can often see EmergentDesign.
http://c2.com/cgi/wiki?CodeSmell
http://c2.com/cgi/wiki?EmergentDesign
Technical debt isn't a sin. It's a tool, but it's a tool that can bite you, so use it wisely! (Analogy: It's the shop owner who should decide when to get a loan to buy inventory, Not The Customer!)
While I'm not the biggest fan of todo lists, well planned and well organized lists do actually help me get things done in a clear and focused manner. If a deadline for a project is looming over my head and I have a handy, well planned todo list for said project handy, I am going to be pushing lots of quick fixes that let me cross things off of my list.
That being said, perhaps this only works well for me because I do take some time prior to writing/adding to the list and attempt to think before I make a list and as such, things turn out better.
I love todo lists as well. Keeps me organised and focussed :)
Elegant solutions tend to have to be part of a phase two initiative to be refactored at a later date.
The flip side for me is the long term todo lists which end up being more like bucket lists of things which 'ought to be done at some point'. I now have four buckets in Trello, 'bucket list', 'next 6 months', 'this month' and 'this week' for general ToDo's (as well as separate boards for individual projects) which mitigates lists like this to an extent as when I'm actually trying to get things done I can just look at the 'this week' bucket.
Daily todo lists have always been a value to me, but I rarely have to actually write them down because of work order tickets or bugfixes semantically being the same thing (to me).
I've had some success doing this with the sub ToDo lists within Trello cards so as it moves from 12 months to 6 months to 1 month to this week it gets broken down into smaller pieces but it still doesn't feel quite right.
In a lot of cases, stuff like this is really just part of the process of learning to be a better coder, and that's not a process that ever really ends. The attitude that poorly done code must either be intentional or is a sign of a bad coder can be toxic in teams, and I think it's important to realize that even good coders make mistakes, and what seemed like a good idea at the time can show it's warts months from now when the shortcomings of a solution is obvious.
I'm paying it back now, actually, as I finalize our public SDK. I don't regret leaving it until now, I would have had unit tests covering stuff we didn't really need for the business.
All of life is trade-offs, no?
No codebase is perfect at any single given point in time, but when you see a broken window, fix it.
http://pragprog.com/the-pragmatic-programmer/extracts/softwa...
There's a social factor to being a professional too; it's not just raw programming skill or experience.
I have no idea what its going to look like.
What I do is just get something on the screen, figure out what's looks "wrong", get it fixed and show it on the screen, rinse and repeat until it looks "right." Then I write tests so that future updates will have something to test against.
How would a "test first" paradigm apply to this? If I don't even know what I'm making, what tests do I write?
If you think that's wrong, then 'test first' isn't always the 'right way'.
No, I'm not being facetious or sarcastic. Just pointing out that 'test first' isn't a requirement. It's an approach that has some good points. I 've done portions of some projects 'test first' and they generally turn, but it's not an approach I use exclusively 100% of the time.
"If you start by writing code you'll end up with the UI that was easiest to code rather than the UI that looks how the end user will want it to."
The problems with this thinking (which I mostly agree with, btw) is that not every project gets to involve checking with end users, nor do end users really understand what/how something should work until they're using something that actually allows a degree of interactivity. They may not even be aware of what's possible until they're poking around 'live'. While you might be reluctant to rejigger large portions of what you've done to move toward "easiest to code vs what they want/need", that's a different problem. It's a problem you need to be aware of, and ready to tackle when you cross it (and you'll know when because you're now aware of it).
This is not at all what pure 'test first' has even been described as to me. You'd write a test - run it to watch it fail - then write the code to make the test pass. Whether that code is interface/ui/logic/whatever shouldn't make any difference.
http://en.wikipedia.org/wiki/Test-driven_development#Test-dr...
"In test-driven development, each new feature begins with writing a test. This test must inevitably fail because it is written before the feature has been implemented."
EDIT:
"Test-driven development is difficult to use in situations where full functional tests are required to determine success or failure. Examples of these are user interfaces... "
The TDD article on wikipedia is seeming to confirm that TDD for UI is hard (or is at least a shortcoming of a TDD approach).
I write unit tests to ensure the correct data comes out. This usually involves doing a quick "get a blank page loading" bit of boilerplate, then putting the tests (and required data) in place. This involves a fair bit of discussion, sitting down with a calculator, and drawing on the whiteboard. Then I write the code to pass the tests.
In parallel, the screens are being designed and put up on our wiki. Once this is done, I'll make the screen look like the mock-up, which involves a visual "test".
For more complex stuff, this is done in a more piecemeal fashion, although the design is usually put in place in one go. What I'm working on right now has involved 4 iterations of this so far.
For what it's worth, writing the tests first forces you to make your code easier to test which, for a web app, is incredibly useful. I've seen some web applications developed without testing in mind, which tend to have the effect of "funnelling" the user through specific steps. They tend to get a little fragile when the user inevitably steps outside the narrow corridor they're pushed down.
It just seems so much easier to include the ground work for feature y while writing feature x. Then by the time it's clear how much extra time it will take to debug and test those bits of groundwork, it's too late to return to a focussed implementation of feature x.
But this demands some designing before programming - and then you are seeing what additional features would be nice to have... and you get my version of feature creep, where you have so many features you "have" to write that you don't have time to release version alpha.