MySQL: Comparing float / double
Posted by mkhairul - October 30, 2009 at 02:10:56 am - No CommentsCategories: Development, Tips
I have not done a lot of raw SQL for quite a while. In my current job, I need to do it. Since we’re using MySQL 4, my options were quite limited as I have to be wary about any features to a specific version (especially > 5).
So I was trying to find how to exclude the amount 0.00 from the result. The obvious one would be
foo.value > 0.00
But the comparison is not precise (I googled a bunch of links, but now they’re gone, you can try to google “mysql float comparison”), I would leave the detailed explanation for you to find out.
The way that I found that fullfills the result that I need is,
ROUND(foo.value, 2) > ROUND(0, 2)
Multiple icons (or buttons) in one image
Posted by mkhairul - August 15, 2009 at 01:08:47 am - No CommentsCategories: Development, Tips
That’s what I searched using google. Didn’t get much, had to browse a few links to see whether it rings a bell. The term that I’m looking for is CSS Sprites.
I’m not gonna reiterate whatever that’s available in the web right now, I’m just too tired. So here’s a list of links for you all to read about it.
- CSS Sprites: What They Are, Why They’re Cool, and How To Use Them
- CSS Sprites: Image Slicing’s Kiss of Death
Its not a new thing, its been around for quite some time but there aren’t many people that I’ve met have actually the need to do it (where performance is crucial for the web site/application). I’m preparing an app for facebook, so these sort of things have to be kept in mind when there’s a possibility (not big, but just in case..) of millions (most probably a few thousand) joins in and beat the crap out of the server.
Here’s an example of a company you’re already familiar with thats using this technique.
Think a little, code a little..
Posted by mkhairul - August 12, 2009 at 01:08:53 am - No CommentsCategories: Development, design, management, rants
Referring to the comment on the post by Mark Needham, Think a little, code a little.
Lazy coding often also takes the form of a “coding frenzy” where the euphoria of programming combined with the anticipation of the client’s happiness when a project is delivered early can cause a situation where the programmer hurries in order to create the single deliverable at the expense of the clean code base. Unfortunately, this often has the opposite of the desired effect later on in the application lifecycle when the technical debt starts to catch up with you, and suddenly your maintenance time is increased and time between releases is decreased. There’s most certainly a balance. One extreme assumes the future, while the other ignores it. We certainly have a limited view of what’s ahead. Assume neither nothing nor everything, but assume something in between. This is what “think a little, code a little” sounds like to me.
I had experienced this in my previous job, where an obvious coding frenzy (or orgy; any act of immoderate indulgence; “an orgy of shopping”; “an emotional binge”; “a splurge of spending” ) have taken place. There is actually very little developer documentation (I was asked to refer to the User Requirement Specification aka URS) for more information, which is totally useless.
I used to prefer going into that ‘frenzy’ mode, coding endlessly for a couple of days to shove it off into the net but when something else came up, I had to postpone the project, to come back to it later (4-5 months), and realized I’m just making a mess.
For a project with a huge amount of CRUD, its better thinking about grace degradation. Don’t just put in javascript to look cool (like facebook, etc) and magically does all the ajax stuffs. I know aesthetics is important for most users, but don’t go down that road too early, it’ll end up being a huge pain.
LSDT: They just want to code.
Posted by mkhairul - April 5, 2009 at 05:04:06 pm - 1 CommentCategories: Development, blog, rants
This is an excerpt from Leading a Software Development Team.
Documentation has some properties in common with design, except that it’s less rewarding. You still need to decide how much is appropriate – who will use the documentation, and what for?
It’s very tempting to say ‘there isn’t time’ and put if off till later, but then of course by he end of the project there’s a huge pile to be done, no time allocated to it, other projecs with higher priorities, and nobody can remember why they did certain things any more.
Even when I haven’t read the book I realized the need for documentation. I’ve been using open source projects for quite some time and I experience first hand how documentation matters. CodeIgniter is great because of the documentation. Other projects soon realized this and start making their docs as good as possible.
Previously, when I wanted to join the other development team using .NET, I requested help from the team members to get me up and running to be able to help them. But the installation and the configuration is so archaic that it requires at least 3 developers present to make it running. This is not the first time, it has happened 6-7 months before. I hope they realized this and start writing some docs on getting started so that new team members can setup the environment on their own.
For those who have only documentation for the user requirements specification, I hope they realized that developer’s documentation is still required so that new developers can get up to speed on the project. I would suggest a minimal design of:
- A block-diagram-level structure
- ERD (or at least tables with description on what it does)
- Some analysis of the dynamics of the system in use (message, data-flow or sequence diagram)
- Coding Guidelines
- And some notes when hitting a wall implementing a design, etc
And if the project is using a flexible MVC framework like CodeIgniter, they should define or describe what the models are doing, what the libraries are doing, its templating structure, and other related info on the implementation. Flexibility invites Tim Toady, so you’d better say up front what this shit is doing and why.
Why?
Because there are different kind of implementations using the MVC, for example like me, Models are only used for retrieving data from the database, it doesn’t do calculation, loops, call libraries or anything like that. Libraries do not call the database.
For libraries, I use it to glue multiple models together, do calculations, algorithms, spread it out to multiple functions to adhere to Single Responsibility Principle (SRP) and many more.
For views, all the code for displaying the data. I have yet to found a developer who focuses primarily on view that I need to use the templating system to seperate between view and controller.
For controllers, this is where the data comes and go. What? Need an event? Retrieve the ID, call the event library and get the details. Pass it to the view and everything else will be done in the view. Calculations are done in libraries.
I wrote in MEDIU’s wiki before this, I don’t know if anyone read it, about writing comments and solving problems. And I’m still trying to stick to this method, whether I wrote it in the code as comments or wrote it as message in the repository.
- Write down the problem
- Think very hard
- Write down the solution
Redesign the Feedback
Posted by mkhairul - March 20, 2009 at 08:03:37 pm - No CommentsCategories: Development, Tips, work
I’m in the process of redesigning the feedback form that the student service department is using.
Why?
There was another request, on 4th March, for the feedback system. I thought I have designed the system to be quite flexible to support a new form. After a week of customization, I realized the work was grueling and there’s tons of stuffs to make it happen but in the same time was afraid of any further forms that will be requested in the future. The load will be exponential for any future forms to add to the system. In the end, the result will be a big ball of mud. I would pretty much like to avoid that, for the sake of my sanity.
I’m not familiar with all the feedback forms that runs a university. 1st, Orientation, 2nd, Lecturer & Tutor Evaluation, after this, who knows?
Since the system is still in its infancy, I made a decision to redesign it, if it is finished late, I will defend it.
Hitting a wall
There was a problem customizing the application to support another form. I tried to create another view for the new form, but the user data have already coupled tightly with the orientation form. Modifying it will require me to modify the new form around the existing user data. I created a content database which will support multiple language (which might possibly be valuable to other university) and easily modifiable content. After that I started creating the form.
The wall that I hit that made me realized is how long that it took for me to add another form. This is insane. I will be stuck with this stuffs if I stay here.
How?
I would redesign the feedback form into a Feedback Creation System (FCS). A system that creates a feedback form. It will support multiple language. Multiple forms. All of it easily and the end user can do this stuffs on their own. If they want to create a form, they will create it themselves.
Development
While developing the newly redesigned system, I read a few stuffs in Designing Interfaces: Patterns for Effective Interaction Design and unconsciously implemented one pattern, one-window drilldown, with another pattern, two-panel selector, which for me looks natural enough at that time. Later on I was like, “Eh?, I think I have seen this somewhere”.
Conclusion
I couldn’t estimate more realistically because of my lack of experience. When there’s a request for 1 form, more will follow. This is my rule on a company or university that is starting up. But never build this kind of system early, because it will take a lot of time and people will give up on it when it takes too long. Build an interim system, in my case the orientation feedback form, to make these requesters happy but in the meanwhile plan for a more proper system that can build all the forms that the users want.
It is easy to lose track of the proper system design and planning, when request and bug reports come in. When an interim system is ready, it is important to have someone to take over the bugs and training for the system. Plan to give only 10-20% of the time for this system and the rest in making a proper system.
If I already have the experience to build a system that creates another application, I would be able to build the interim system more properly so that the data can be reused (or easier to migrate) on the final system. But I do not have an experience required for that so the current one is a dead end. I need to convert the data someway into the new system. Thats it for now for FCS.
Language List for Applications
Posted by mkhairul - March 19, 2009 at 10:03:26 am - No CommentsCategories: Development, Tips
Previously I have posted a list of countries to be kept in the database for applications. Now, language list for applications. The language list uses ISO 639-1 codes.
Now I know why the arabic language code is called ar. Heh.
Here’s an SQL dump of the language list.
A vision of an almost perfect development environment
Posted by mkhairul - March 18, 2009 at 03:03:46 pm - No CommentsCategories: Development, Tips, rants
I used to have a vision, where the development team all log reports, requests and issues in the Issue Tracking System. Wrote adequately enough information for the issues, and discuss it with their peers.
For each issues, if its common issue, the process for it will be written down in the wiki. Emails will be sent around to review the process, and people would contribute to it. Enhance it, make it better by sharing their knowledge or insights. Everyone communicates.
Every week, we would all gather to review and discuss the issues that have been logged into the system. We would think of a way to improve ourselves instead of doing the ways we think that are best on our own. The issue tracking system is being used as a tool to leverage our knowledge to each of our team members.
In time, we have a repertoire of knowledge accumulated from this practices, that newcomers have no problem getting started into the team.
Tis only a dream, too far fetched and too hard to achieve, alone. It is like trying to swim upstream through a river, eventually, everything is worn out. I can only hang on to a branch or a rock to gather my strength before continuing my battle.
Getting Started #1
Posted by mkhairul - March 18, 2009 at 02:03:57 pm - No CommentsCategories: Development, Tips
My initial getting started to finish up a task (mostly for development).
- Log task in TaskCoach
- Write down the problem
- Think very hard
- Write down the solution
- Commit into subversion
Iframes have a negative impact on web pages..
Posted by mkhairul - March 13, 2009 at 09:03:46 am - No CommentsCategories: Development, Tips
Taken from Google Code Blog,
Iframes have a negative impact on web pages. They are the most expensive DOM element to create. They block the parent’s onload event (although there’s a workaround to this problem in Safari and Chrome). Also, the main page can block resources in the iframe. It’s important to understand these interactions if you use iframes in your page.
I have read numerous post and articles on iframes on why you must not use it (but I didn’t bookmarked it, it was pre-delicious era). So every time when I wanted to use iframe, I have this tingling on the back of my skull, sort of like spider-sense, and search for other methods.
Country List for Database
Posted by mkhairul - March 12, 2009 at 03:03:44 pm - 1 CommentCategories: Development, Tips
I couldn’t find a country list that I like. The ones that I found were only country list, no country codes. Currently I’m using the ISO 3166-1 country list.
Converted the list into a mysql dump. You can download it here, country list.
GimpStyle Theme design by Horacio Bella.



