Devlico.Us
CodeBetter.Com
RSS 2.0 via Feedburner
           Do you Twitter? Follow us @devlicious

Sergio Pereira

There are no half-solutions because there isn't half a problem
  • Performing Code Katas

    I just came back from the first meeting of the Software Craftsmanship Group. Tonight Micah Martin talked about Code Kata but added an extra facet to it.

    Micah proposes that, although practicing the Katas by yourself, in your spare time, is valuable, presenting your routine to an audience can deliver even more results. For the presenter there is the opportunity to gain feedback from the audience (peers, masters, even pupils.) For someone watching there's the chance of seeing another peer (or even a master) in action and learn how other developers approach problems and construct their software. By the way, it takes a non trivial amount of courage to sit in front of an audience and write code, even if you have practiced it several times beforehand.

    To demonstrate this concept, Micah created a Ruby program that implemented Langton's Ant. I'll try to illustrate the results of this experience.

    The audience - me (and many others)

    Once Micah explained what the problem was, he asked that we watched him code and be prepared to evaluate his performance (quality, smoothness, clarity, etc.)

    Although I know a little bit of Ruby, I'm by no means a proficient Ruby developer yet. Seeing someone that works with the language all the time in action would be interesting no matter what. But there was more in it for me.

    Micah, as a true BDD pratictioner, started by creating the specs with RSpec and proceeded with the red/green/refactor iterations until he achieved a complete successful specification execution.

    There's nothing like seeing a technology at work to understand it better. Tonight's performance contributed a lot for my BDD understanding.

    The presenter

    After the presentation we had to rate it (0 to 10) and give some feedback. There's where the other Ruby and BDD ninjas in the room could make educated comments about Micah's performance and average joes like myself could comment on less sophisticated issues like font size and keystrokes.

    Judging by the constructive feedback, I'd imagine the presenter's future performances will be fine tuned and get better. On that note, the suggestion is that the presenter moves on to a different Kata for each performance.

    Buncha' Links

  • New Software Craftsmanship Group

    It's so rare to find interesting group meetings up here in Suburbia that I can't pass the chance to attend new ones.

    As Micah Martin announced, the Software Craftsmanship Group was created and the first meeting happens soon.

    One of the topics for the evening will be Ruby Kata. Should be fun.

  • Chicago ALT.NET - The aspects of AOP

    The October 2008 meeting of out user group will be held next week, Wednesday the 8th. The chsen topic for this month was AOP.

    Core: An Aspect Oriented Business Objects Framework

    6:00 pm
    Pizza and networking time

    6:30 pm
    Learn about aspect-oriented design patterns and how they can be used to quickly add common functionality to your business objects. Josh Heyse explains how Aspect-Oriented Programming allows for the separation of true business logic and the code written allowing interaction with user interfaces. The Core framework is a generation model that dynamically adds common services, such as logging, auditing, persistence, and security to business objects. Aspects, or behaviors, are requested using attributes or configuration files which allows services to be included only where necessary eliminating overly bloated objects and tailored for the environment into which the object is loaded.

    7:45 pm
    You may want to stick around after the presentation portion of the meeting and take part in our monthly open discussion. The topic is never arranged in advance but it's common that it reflects the content of the presentation.

  • TIP - Disable full row selection in Vista's Explorer

    I've been using Vista since the official release (skipped the betas) and I've been trying to convince myself that some of the changes were made for the better.

    In particular, I've made some effort to get used to the new file explorer but somethings have been harder to put up with. Anyway, little by little I "fix" some of the new features.

    Today, I had it with the unnecessary full row selection. It makes right-clicking the directory listing background much harder. The fix isn't trivial. It involves setting a bunch of flags in the Explorer settings in the Registry. The good news is that you can get it in a .vbs file (I don't recommend downloading and executing scripts from the Internet, so open the file in a text editor and inspect what it does to make you feel comfortable with what it does). There are other handy utilities there as well.

    Next up is changing the selected/hovered-over item's background color in Explorer (Aero). That choice of blue is way to pale for me. I've read that it cannot be changed easily because it comes from a bitmap embedded in the theme itself.

    By the way, I'm mainly using Windows Server 2008 with Aero turned on and the fix works there too.

  • Created with Community Server

    Don't you hate when tools try to promote themselves in your work, especially if you paid for them?

    Last night I was noavigatin around in Reflector when I stoped by the embedded resource named System.Data.Odbc.OdbcMetaData.xml (in System.Data.dll 2.0). What I saw was both familiar and a little aggravating.

    <?xml version="1.0" standalone="yes"?>
    <!-- edited with XMLSPY v5 rel. 4 U (http://www.xmlspy.com) by Carl Perry (Microsoft) -->
    <NewDataSet>
        ... xml content here ...
    <NewDataSet>
    

    In a way I also felt vindicated that MS is also a victim of this shameless, intrusive advertisement after inflicting it on many others as well (I'm talking to you ASP.NET HTTP Headers). BTW, thank you Visual Studio webforms designer for getting rid of those Meta tags you once put in my pages.

    What other big offenders are out there? Free tools need not apply.

  • Video - ORM Discussion/Fishbowl

    After the IoC talk we had the monthly discussion. This time we tried the fishbowl format (or some approximation of that). The topic was ORMs.

  • Video - IoC with StructureMap

    I finally got some time to import and upload the videos of September's Chicago ALT.NET meeting that happened almost 2 weeks ago.

    In this first video jdn shows how DI and IoC containers can be used to add flexibility to an application design.

  • The bug that almost drove me mad, and it's not my bug

    No bug in Windows (XP and 2003) has annoyed me more than the one I just learned how to get rid of.

    For no discernible reason, while using the Windows Explorer the treeview on the left would just go bananas and display multiple Desktop icons. As seen in the following image. The additional Desktop icons sometimes had other Desktop as children. A recursive bug, nice.

    I had been experiencing this bug for many years in both XP and 2003. The most frustrating part of it was that anyone seemed to have seen similar bug on their boxes. I had that problem in every single XP or 2003 boxes I had ever had. Including virtual machines. That led me to believe it must have been caused by some software that I use on all boxes. Nope. Keep reading.

    After years of internet searching for people with similar problem, posting to message boards, and almost scheduling an appointment with a shrink, today I found this thread with other poor souls suffering of the same pain.

    Without further ado, I present you the culprit.

    Yes, my friends. The seemingly innocuous and handy Desktop taskbar toolbar has been that thorn, that little and continuous disturbance that contributed to loss of precious hours of my working and leisure time (when computing all the times it happened in the last 6+ years I've been on Windows XP). Removing that toolbar from my taskbar made the problem go away. I have the same toolbar on my Vista and 2008 taskbars and have yet to see that problem there.

    Apparently an abysmal fraction of Windows users care for that toolbar so nobody cared to report the bug. That or everybody else was aware of that bug and skipped the toolbar altogether. In either case, poor me :)

    Today I'm glad to cross out that problem from my infinite list of things to figure out some day. I can still get a working Desktop toolbar by adding a new toolbar that points to the Desktop directory in my user profile directory. It does not combine with All users but it's good enough for how I use it.

  • Tip: export to CSV using ADO.NET

    A friend of mine was telling me about a bug he found in one of his applications caused by a simple lack of escaping quotes when producing CSV files. It immediately reminded me of an old trick in .NET.

    If you really want, you can create CSV files using ADO.NET and OLE-DB (or ODBC.) I wouldn't necessarily recommend this approach but it is definitely one of those things that when you see for the first time you go "I never thought this could be done this way."

    The idea is simple — open an OLE-DB conenction using the Jet OLE-DB provider, create a table (which is really just a file) and insert rows in that table (or lines in that file.)

    //create a temp directory for the CSV output
    string tempFile = Path.GetTempFileName();
    File.Delete(tempFile);
    tempFile = Path.GetFileNameWithoutExtension(tempFile);
    string dir = Path.Combine(Path.GetTempPath(),  tempFile );
    Directory.CreateDirectory(dir);
    string csvFile =  Path.Combine(dir, "data.csv");
    
    string cnStr = 
        "Provider=Microsoft.Jet.OLEDB.4.0;" + 
        "Extended Properties='text;HDR=Yes;FMT=Delimited';" + 
        "Data Source=" + dir + ";";
    
    using (var cn = new OleDbConnection(cnStr))
    {
        cn.Open();
    
        //define the file layout (a.k.a. the table)
        var cmd = new OleDbCommand(
            "CREATE TABLE data.csv (CharColumn VARCHAR(30), IntColumn INT)", cn);
        cmd.ExecuteNonQuery();
    
        //start pumping data
        cmd = new OleDbCommand(
            "INSERT INTO data.csv (CharColumn, IntColumn) VALUES (?, ?)", cn);
    
        //in a more realistic example this part
        // would be inside some type of loop
    
        //1st record
        cmd.Parameters.AddWithValue("?", "11111111");
        cmd.Parameters.AddWithValue("?", 1234);
        cmd.ExecuteNonQuery();
    
        //2nd record
        cmd.Parameters.Clear();
        cmd.Parameters.AddWithValue("?", "22222\"22222");
        cmd.Parameters.AddWithValue("?", 6789);
        cmd.ExecuteNonQuery();
    
        //etc...
    }
    
    //read the csv formatted data
    string csv = File.ReadAllText(csvFile);
    
    //cleanup
    Directory.Delete(dir, true);
    
    Console.WriteLine("Result:");
    Console.WriteLine("--------------------");
    Console.WriteLine(csv);
    Console.ReadLine();

    The output of this will be as follows. Note the escaped double quote in the last line.

    "CharColumn","IntColumn"
    "11111111",1234
    "22222""22222",6789

    Of course, you can also read from a CSV file with simple SELECT statements against the file. You can let ADO.NET take care of all your typical CSV tasks.

    Fabrice Marguerie wrote about this same topic a long time ago (check the comments and links too).

    You may also want to check a more structured approach to the Export to CSV problem by way of the FileHelpers Library.

  • Transitioning - part III - enter the learner

    Turning the table

    So here I am, the guy often in charge of assisting new developers get up to speed with my designs and code, facing the diametrically opposite situation.

    Like many other developers, I have changed jobs more times than I'd like to. I love the chance to learn from a new industry or platform, I just wish the transition wasn't as traumatic as it frequently is.

    I've seen developers hit the ground running, but I've also seen other developer struggle and run in circles not knowing how to proceed when faced with the new environment.

    I believe each place has its own challenges but it's still possible to follow some guidelines (or more like heuristics) to optimize the whole ordeal.

    Humility - leave that big ego at home

    This may be sad news to you, but it's probable that you'll be facing several brick walls. That has nothing to do with your skills or how great a problem solver you are. It doesn't matter. The environment is new to you, possibly the business itself is completely foreign too.

    So ask! You will not be perceived as incapable just because you ask too much. Yes, at least try to solve the problem, but don't go thrashing for hours and hours. You have too much too learn and not a lot of time.

    Identify the key players

    Maybe you will be introduced to the team in you first day and tons of job titles will be thrown at you. Don't spend too much energy trying to remember who has what position in the org chart.

    More often than not, these titles have very little to do with the actual role each individual plays in the team or project. Just because someone is labelled senior developer it doesn't mean that that person's contribution will be more effective or regarded than that lowly intern that is on a Summer job or even somebody not directly in the team, like a business user.

    Knowing who really has the information you need should always be one of the priorities in your first week at the job.

    Identify the real mentors

    You know how that is, someone gets the task of being the assigned target for your questions or for pairing with you for a tour of the system. What may not be obvious is that your assigned mentor may have been appointed and not volunteered for that task.

    It's possible that there are other members in the team with more inclination for mentoring or that is better at explaining things. So why was not that person chosen to be you mentor? Who knows... Too busy? He/she was on vacation when you started? Bad management? It's uninportant. It happens. It sucks.

    Bottom line, disregard the assignments and go for the gold. Once you discover the mentors in your new team. Jump at them. The real mentors will be happy to make themselves available to assist you.

    Pick your battles - everybody has defects

    The temptation to point out problems is ginormous when you start. It's understandable. You want to show something you know, to contribute, to become valuable, etc.

    The unnecessary risk in that is putting yourself in an antagonistic role. It's hard enough being the new guy. Being the guy that came to make us look bad is definitely undesirable. The system had those problems before you got there, chances are nothing serious will happen if you wait a little longer to understand the ground you're stepping on.

    Unless you were brought in specifically to review or address a particular problem, exercise your best judgment and don't stick your finger at every little flaw. Everybody has shameful code in their source control log.

    Learn the business, talk the talk

    New job invariably brings a different way to do business, maybe a new industry altogether. We will do a huge favor to ourselves if we make an effort to learn this new business. Learn the jargon, learn the business model, learn why your end users are using the software, learn about the competition... Learn.

    In any semi-serious shop, just knowing the business lingo should give you a head start in understanding even classes and table names in the system. Not to mention you will be able to sustain a decent conversation with the business stakeholders more quickly.

    Jump at the opportunity

    To top it off. I've seen these countless times, and it still saddens me. Everywhere you go, every team, every project, there's tons of stuff that could be better if someone dedicated some time to it. Unfortunately the lack of initiative is a plague that affects not only software development but pretty much every field. It probably had more to do with sociocultural roots than being a bad professionals.

    How many times you've heard complains or suggestions flying by in team gatherings along the lines of: "Have you guys ever used a wiki? It would be cool if we had one", "Our [ bug tracking | source control | logging component | 3rd party controls library | insert pet peeve here ] sucks, I wonder if there's anything better out there", "We seriously need to take the time to document this API", "I hate doing this every time. This should be automated". Let's try not to look at these statements as merely problems or chores that represent the status quo and be prepared to deal with them. In reality these are examples of opportunity. Things that nobody in the team likes or knows how to do. More importantly, many of these can have a direct impact on how well things work, more than it may be apparent. Oh, that's right, they can be fun too.

  • Transitioning - interlude

    Right after I mildly complained about the lack of thoughtful orientation on a new job, I was pleasantly surpirsed with this lovely schedule for my first week at the new place.

    Just wanted to share that with you. There's hope for our world.

  • Chicago ALT.NET - IoC Containers

    Next Wednesday, September 10th, is the next meeting of the Chicago ALT.NET user group. This time IoC containers will be the topic du jour.

    Expect to see an introduction to this technology and learn why IoC isn't just overhead. Don't expect to leave with just another introduction to some technique that you'll never want to use.

    Inversion of Control for the masses

    6:00 pm
    Pizza and networking time

    6:30 pm
    John Nuechterlein (a.k.a. jdn) puts Inversion of Control (IoC) containers under the spotlight. If you have been noticing the increasing buzz around this technology but never had a chance to see what it is and how it can be used, this is your chance to see:

    • An overview of what IoC is, using StructureMap as the example
    • Why one might want to use IoC
    • How one can implement IoC
    • When one might not use IoC

    7:45 pm
    You may want to stick around after the presentation portion of the meeting and take part in our monthly open discussion. The topic is never arranged in advance but it's common that it reflects the content of the presentation.

  • Transitioning - part II - oh, the expectation

    Nothing like a long 3-day weekend to help forgetting about the old problems from your previous job. This should help making room for the upcoming avalanche of new information and ramping up on the new gig.

    Show me where the North is

    I'm also taking this short interval to revisit my previous experiences of changing jobs and what waited for me on my first few days. I think that in all the other transitions only once there was an orientation process in place to assist the new guy learning the ropes. The common approach has always been to give a brief half-day or less introduction to the system, show how to get the source code, show the database diagram, meet your team leader, webmaster, DBA and manager, then go fix some bugs or build a prototype of a new feature.

    I can't say that style of orientation (or shall we call it hazing?) can't work. It may work for some types of developers and worked for me, but it's risky and painful. It's also fuel for misunderstandings and propagation of myths. I won't lie and say that I could completely understand the entire system just by reading the source code and outdated documentation, it often happened that I had to grab any chance I had with more senior team members to ask questions that other developers in the same situation as myself could not answer.

    The phases of a new job

    a.k.a.: From "what the..?" to "yuck" to "a-ha!" to "this is great" to "this can be better"

    I wanted to write this before I even look at the source code that waits for me because I don't want my new team mates thinking I'm talking about their master-piece. Again, I'm referring to my previous job/client changes.

    One thing that invariably happens with me when I start reading unfamiliar source code is that shock of dealing with different coding styles, different coding standards, different 3rd party libraries, and sometimes different programming languages (or versions).

    A lot of the discomfort is caused by superficial issues like naming conventions that temporarily obscure the understanding of the important characteristics of the system. We shouldn't be distracted by these conventions or code formatting style. What we are really trying to understand and get up to speed with is how the product was designed and which are the important components and identifiable patterns we need to adopt. It's okay to start off writing code with disagreeing naming styles, these things are easy to fix. Misusing or not using the design principles applied in the rest of the code is way more costly to fix, demanding more careful refactoring.

    Once we start to see through that noise, we will finally be able to understand the why's and how's of the system. With that understanding comes an increasing sense of admiration for the code. I'm not saying that you will agree 100% with what you see, but at least you can feel more confident that you know what you're stepping on.

    With that confidence in place we can start to identify places in system where cracks can start to show or more appropriate solutions for some of the issues. In general, we start to be able to contribute more than just code, but also design options.

  • Silverlight at the LCNUG

    Last night I attended another LCNUG meeting. I think it's great that we have this new group forming in the northern suburbs of Chicago. It's definitely not easy for us suburbanites to attend CNUG's meeting in the West 'burbs or even the Chicago ALT.NET meetings downtown. It's special convenient for me because it's only 10 minutes from home.

    This time the presentation was about Silverlight. Tim Stall gave us a very nice and engaging rundown of this new technology — it was not your off-the-mill introduction talk. The questions from the audience were very interesting and Tim was very honest about the strengths and shortcomings of the tool. It was especially interesting to discuss ways to bring SilverLight into your organization.

  • Transitioning - part I - getting out

    Consulting engagements are supposed to end, even after 4.5 years. So, yes, my current assignment with the client is scheduled to end this week (is this job change season?). I didn't honestly expect it to last that long when I started but I guess the balance is positive.

    With the end of the assignment my current priority becomes making sure I leave applications that can be maintained by the in-house staff. I can see at least 3 aspects that can impact the success or not of the transition — but only of them can be dealt with at this point. Read on.

    1 - Design with maintainability in mind

    That's where a truly successful transition starts. Of course there are situations where maintainability is not at the top of the list (think short-lived applications,) but we wouldn't even be talking about transition in those cases.

    For all the other situations, which has been most of them for me, maintenance has to be factored in during the pre-coding stages of the project. That's when your senior developers will use their experience to identify potential support trouble in the solution design, before they come to life.

    On that front I believe we did a good job within our limitations. I believe the applications were conceived with careful consideration to maintenance and, whichever parts of them created maintenance overhead, happened because of honest ignorance — not sloppiness. So check that off.

    2 - Involve the maintenance staff during development

    Without becoming annoyingly obvious here, it's always beneficial to have more than one developer knowledgeable about any one part of the application. Be it through code reviews, pair programming, or some other mechanism.

    That's especially true for consulting engagements. Raise the red flag whenever you see a situation where only consultants/contractors are working on a project that is expected to be maintained by the client's staff.

    Unfortunately the prominent structure of a project team at this client only included a single developer — sometimes an employee, other times a consultant. That was not something that I was ever in a position to change. I raised that flag but... oh, well. Whatever.

    3 - Knowledge transfer of the parts you own

    If the first two items were taken care well, the knowledge transfer can be just a formality. The less effectively we take care of #1 and #2, though, the greater the pressure on #3 will be.

    When transitioning parts of the application that you're the only one that is familiar with, then there are several things to consider: existing documentation, the background of the people taking on the application support, the fancier parts of the code, the embarrassing parts of the code, and the design principles behind it all (if any.)

    I think documentation is important but it only goes so far. There are many things that will require sitting in front of the screen, opening the code and/or database, and explaining how things flow.

    It's also important to know the style of each developer. If you are dealing with a data-first type of programmer, then you have to make sure enough time is given to discuss the database design. Conversely, if the developer is an objects-first subscriber, the business objects in your code will deserve some more attention. The type of developer you are will also affect this discussion.

    I try not to be excruciatingly detailed in the transition to avoid burning out the other developers before they even start touching the code. I try to leave some things that seem clear enough to be discovered by them as they go.

    Lastly, if possible, stop taking on support tasks for the application being transferred and have the new crew take care of them while you're available to help. This will also help guiding the knowledge transfer meetings.

    In my case I knew I was in trouble for being the only developer on the project(s) so the transition meetings became inevitably numerous and lengthy. In a way I was lucky that I knew I'd be leaving the client more than a month in advance so I could prepare better for this. Being with that client for such a long time also helped knowing the other developers well enough to make a list of items I really wanted to ensure got the necessary talk time.

    I don't think it is possible to leave the client thinking 100% of the possible issues are understood, but we are doing a responsible job of covering our bases. At minimum I know the code is in good hands.

    Good advice is always welcome. Do you have experiences to share? Anything I could take care of in the next five days?

More Posts Next page »

Our Sponsors

Red-Gate!