• Using Fluent NHibernate to generate your database

     

     

    After my data access debacle at c4c I decided to sit down and give NHibernate a serious look again… so I can feel comfortable with it. It was still bothering me that I had to deal with xml configuration files (In addition to app.config/web.config). I really having to hunt down so many config files.

     

    Alas, the answer for that problem is Fluent NHibernate. I had heard the name mentioned before but I didn’t know what it was. Basically, there is no need to create mapping xml files, you just create mapping classes using lambda expressions in code. This gives you intellisense (yay for us lazy people)!

    http://fluentnhibernate.org/

     

    So to start learning Fluent NHibernate I was looking through the ‘first project’ example and remembered something Lee Brandt told me at C4C, “you can generate the sql ddl from within NHibernate to deploy your sql schema”. Fantastic! I wondered if I could do this with Fluent NHibernate too.

     

    The answer.

     

    Yes you can create your database from code using Fluent NHibernate… here is basically the snippet of code that had to change from the “First Project” example linked above:

     

           private static ISessionFactory CreateSessionFactory()

            {

                return Fluently.Configure()

                  .Database(MsSqlConfiguration.MsSql2008

                                .ConnectionString(c => c

                                .FromConnectionStringWithKey("connectionStringKey")))

                  .Mappings(m =>

                    m.FluentMappings.AddFromAssemblyOf<Program>())

                      .ExposeConfiguration(cfg => new SchemaExport(cfg)

                                                      .Create(false, true))

                  .BuildSessionFactory();

            }

     

     

    Now, you would only run this program once in this case because during the creation of the session factory we are generating the database (which would probably fail if you ran the program again).

     

    My thought is pulling it out into a method of it’s own to initiate only if the database doesn’t exist yet. Also, you could work in asking the user to enter in the connection information for the database server.

     

    Full story

    Comments (0)

  • Google bringing Gigabit Internet to Kansas City, KS

    http://www.msnbc.msn.com/id/42342322

    Read up... I personally haven't had a chance yet, but this is exciting news that will hopefully further break up the ISP monopolies and create better private sector competition and growth.

     

    Full story

    Comments (0)

  • C4C Recap and Lessons Learned

    As I was hacking around at Coders for Charities on my attempt at reproducing the Row Data Gateway Pattern from "Patterns of Enterprise Application Architecture" by Martin Fowler. By hacking around... I mean that I tried to be a good saint and start with using TDD, but after becoming completely bored with unit testing each added parameter to the SqlParameterCollection within a SqlCommand object I became completely disenchanted with the idea of doing that for the next 24 hours and not being any closer to a "Working Product".

     

    So... I wrote one unit test, testing the 'pattern' of what I was doing...then once end-to-end worked... I gave up the TDD.

    By all accounts this was the most cut and pasted code I've probably ever written...

    stuff like this:

    command.Parameters.AddWithValue("@parm1",Value1);

    ...Over and over for insert, update and deletes...

    Which... this was all because i felt that Entity Framework or NHibernate in a 'Time Crunch' situation would just be too much overhead...

    Sure... I was probably wrong :(

    And so anyhow, here I hacked away on my little slice of the pie... with no source control. Paul Meinhardt was jammin' out the SQL Database Table and SSIS import from Access, Cody Inman was rockin out the Sitefinity Skinning and several other sweet integrations (Paypal, Google Maps, Image Library), and Ross Fuhrman was writing an Excel export so the Business users could still do business the way they have for several years successfully.

     

    quick tangent: don't change how business is run and do not change how the data is stored (1 table, many columns) when you only have 2 days to do stuff.

    All of us split up doing our 'own thing', but integrating fairly decently, and finally coming down with a damned fine product in the end (I think) for what amounted to less than 25 team hours worth of work.

    Everything came out pretty damn nicely I think...

    The fruit of our labor: www.beltoncemetery.com

    So what were the key factors in our success?

    1. Onsite customer. Our customer stayed there most of both days with us and fielded questions. We probably under utilized them to be honest...
    2. Continuous Integration. We had the fully working site (but minimal) site deployed to discountasp.net by 10am in the morning on Saturday and we updated it religously and testing things (mostly manually) throughout both days. Always making sure it was working and we hadn't broken eachother. Then when we did... we talked and fixed it!
    3. Team communication/Collocation. We were tightly grouped together and looking at eachothers screens for the most part. It was amazingly wild.
    4. Energy Level and Fun. We tried to keep joking around and having fun. It's intense (especially when it's 80 degrees in our room because the AC was broken) when you're locked in together and working very hard... and breaking eachother's code and telling eachother how to do things :) :) (OMG u changed the data types! or 'Ugh all in 1 table?")

    So what would I do differently though?

    1. I need to learn an ORM so i can be successful at TDD in this type of situation.
    2. I need to get an IoC container setup next time so I can focus on just the interactions between presenters and the views. (Wasn't really a BLL in this app nor will there usually be in these types of apps)
    3. We need to get some sort of source control next time... people need to learn svn or git or somethin :)
    4. NOT use ftp remote site in VS2010
    5. bring a laptop for Ross
    6. Bring Vm we can all use with the same toolset
    7. vote an initial dev toolset before the night of! (pending the organization wanting something different ofc)

     

     

     

     

     

     

    Full story

    Comments (0)

  • Scrum-a-thon and on and on

    Is your scrum meeting going wildly out of control but you really want the team to self-manage it?

     

    Try this tip (forwarded to me from Dale Sawyer, originally from his CST... Jim something... sorry Jim, I don't know your last name)

    The concept of the squeaky toy:  


    There should be a bunch (6 or more) of these squeaky toys placed on the center of the table where you meet.  Initially the scrum master will always have one and you will ask the PIGs in the room to grab one too.  As the scrum master, you will explain that any PIG should squeak the toy if the topics get out of bounds or take a tangent.  In order to help the room to GET IT, the scrum master should occasionally, intentionally ramble about stuff, and call himself out with the squeaky toy.  After a couple of these the rest of the team(PIGS) should start squeaking when appropriate.  That is when you know the team GETS IT and will start using them during the meeting to call attention to non-standup (not the same as unimportant) business.  This tool, makes the team responsible for calling people out that monopolize the team's time.  It makes the team more aware of their focus, as well.  It takes the focus off the scrum master for keeping the standup on task, and back on the team, as it should be.

    Scrum masters do not run stand-ups, scrum teams do.

     

    My thoughts (I haven't tried it just yet... though I plan on using it soon)

    have enough for each person and hand them out at the beginning.

    if you squeak wrongly then you sing I'm a little teapot or dance in the circle.

     People could hold them behind their backs so they don't really have to feel as 'guilty' for interrupting.

     

    i was also thinking it would be cool to use the Dave Chappele "Wrap it up" box

     

    Full story

    Comments (0)

  • Exciting Month in March

    There are a couple of programming/software events coming up this month that I would love to have everyone be aware of and join us for.

    KC .Net Users Group Meeting

    Mar 22

    6:00 PM - Monthly Meeting

    Tue, Mar 22, 2011, 6:00 PM - 8:00 PM

    http://kcdnug.com/

     

    Centriq Training, 8700 State Line Rd, Leawood, KS 66206

    Presenter: Tom Collins
    Topic: .Net Micro Framework
    Sponsor: Adecco

    Agile KC Meeting

    March 24th

    Greetings all,

    The next Agile KC meeting will be at the Pizza Shoppe at 6:30 PM on
    Thursday March 24, 2011.    Please check teh website  www.agilekc.org
    if you need a map or directions.  This is the re-scheduled topic from
    February.

    The meeting topic: Behavior Driven Development (BDD)
    Interested in BDD?  How does it fit with TDD?  Within the SCRUM
    framework?  What is BDD?

    Come out to see some tools, tricks and tips on how to leverage these
    questions and fit it within the SCRUM framework to help answer the
    ultimate question of "What is done?".  Patrick will show some of the
    tools and tricks that he has acquired over the years to leverage
    these
    into the SCRUM tool set.

    Who is Patrick Liekhus?
    Patrick has been a team member in the Kansas City market for over 15
    years leading several SCRUM oriented teams through various
    industries.  Patrick likes to refer to his role on the teams as a
    "coding architect" where he leverages the patterns and practices into
    hands-on applications.  Patrick is a Certified Scrum Master (CSM) as
    well as Microsoft Certified Trainer (MCT) and Microsoft Certified
    Professional Developer (MCPD).

    Hope to see you there!

    Martin Olson

    Coders 4 Charities

    March 25th-27th

    Coders for Charities is coming up this month. It is near and dear to me because my father, Ronald Peckham is a dedicated and accomplished non-profit volunteer and worker. It's definitely true that I cherry pick how I contribute... but it can't get any more fun that programming for 2 days straight! I guess I donated clothes last month that counts, right? L

     Sign up for coders4charities on their site:

    http://coders4charities.org/Event.aspx

     

    Hope to see everyone at these great events in our city to show the love.

     

    Full story

    Comments (0)

  • VS10x CodeSmart cool feature

    I had never heard of this tool:

    http://visualstudiogallery.msdn.microsoft.com/1c54d1bd-d898-4705-903f-fa4a319b50f2/

     

    but basically i've given it a quick glance and am giving it two thumbs up (with the only negative thing being it takes up some horizontal space on my display (get a wider screen monitor to combat this or 2 monitors)

     

    My favorite feature is you can put in comment //BMK <Some text> and book mark your code. I know a lot of people use the 'back' and 'forward' navigation commands to scroll back to where they were but I find this more natural to me as i may jump around in a large code file (sorry real apps end up having large code files someimes) and lose my place pretty quickly. Backing through all the places i've been may not be the answer. Plus if i end up changing something in a different method 200 lines away from where I was then this gets me right back to where I was with a single click.

    just put in //BMK Where i'm working then do my thing. It's a great way to keep track of where i'm at in a unit test code file too.

     

    Full story

    Comments (0)