If only I were

Building Great Software

Posts Tagged ‘Data

Function-centric to Data-centric to Model-centric

with 2 comments

I picked up book called The Waite Group’s Object-Oriented Programming in Turbo C++ recently to look at what Robert Lafore was saying about OOP 17 years ago. The book was published in 1991. I’ve just read chapter one at this point, but it was rather interesting.

Before we look at Lafore’s views, lets talk about where we are now.

A fairly common complaint we hear in 2008 is that people write their programs in a very data-centric way. They write objects for the sole purpose of CRUD but the life of the application in is the database. They might throw in bit of inheritance to make their objects feel more OO, but end of the day they are making glorified data containers that map directly to the database tables.

I was recently in an interview where one person admitted that it was easiest to start with the database and work out from there. So their “business objects” were just in-memory data containers for performing CRUD with a few useful utility methods hanging off the objects.

If you talk with people working with NHiberate, people doing DDD, an Alt.Netter or Rocky Lhotka (I realize there are very diverse view in these groups), you’ll get the view that your domain objects or your business objects should be the core of your application. I buy into this view by the way; the database is a good place to persist your data, but it shouldn’t be where you start in application design.

So what was Robert Lafore’s concern with procedural programming? Remember that in 1991 OO wasn’t mainstream. Here is a direct quote from a section called Data Undervalued in Chapter 1:

What [functions] do may be more complex or abstract, but the emphasis is still on the action.

What happens to data in this paradigm? Data is, after all, the reason for a programs existence. The important part of an inventory program isn’t a function that displays the data, or a function that checks for correct input; it’s the inventory data itself. Yet data is given a second-class status in the organization of procedural languages.

He goes on to explain that functions/methods/procedures don’t let you model the world very well. How do you model a windowing system with dropdown menus with just methods? And he is right, there needs to be more than verbs in our programming languages, we needed first-class nouns (beyond local variables) to be able to model the world better.

17 years ago coding was too action centric but Robert claims it should have been more data-centric. Now that OO is fairly mainstream coding is too data-centric, and the claim is that we need to be more model-centric.

None of these views stand on there own. If you took away functions we wouldn’t have programming; if we didn’t have data we wouldn’t have a reason to program. But I think that building out a good model that is object based and is independent of the database is just as important for application design.

What do you think about this progression? Where are we going from here?

kick it on DotNetKicks.com

Written by Chris Sutton

August 9, 2008 at 11:01 am

Posted in Learning, Technology, Thoughts

Tagged with , , ,

Twin Cities Code Camp MVC Session

with one comment

Thanks to everyone who attended my ASP.Net MVC session. I hope you enjoyed it and I hope you get the opportunity to try out what the MVC framework has to offer. The slides have a lot more information than what I was able to get through in my talk. The project is still very young, but has so much potential.

Please leave comments here and let me know what you thought of the session. I’m trying to constantly improve it to make it the right fit.

More ASP.Net MVC Slides.

Written by Chris Sutton

April 8, 2008 at 11:41 am

Twin Cities Code Camp IV

with 3 comments

Yesterday, I was in the Cities at the fourth Twin Cities Code Camp.  It really was a fantastic experience, likely the the best one yet (I presented at the first two code camps as well). From the presentations I attended I would say that the quality of the presentations was very high. They easily would rival what you get at a paid conference. I also met a bunch of people I had never seen in person which is really cool.

Some of the Iowa crowd that went up was Javier Lozano, Bryan Sampica and Greg Wilson. There were several other attendees from Bryan’s company as well. The Iowa presenters and attendees have grown significantly since the first one where I was the sole Iowan as far as I know.

Some interesting people I met/saw were D’Arcy Lussier, Neil Iverson (Inetium), Brandy Favilla (New Horizons), Robert Boedigheimer, Chris Williams (Magenic), Aaron Erickson (Magenic), Kent Tegels (DevelopMentor), Jeff Ferguson, Chris Johnson, Saviz Artang, John Thurow, Kirstin (Magenic), Nicole and Kristen (New Horizons) and Justin Chase.

My favorite session was Neil Iverson’s PowerShell for Developers.  It was a fast paced live demo that kept incrementally building.  Rarely have I been so engaged in a session. D’Arcy’s MVC vs ASP.Net talk was also really interesting.  We only had about 6 people in the session, so we went around the room and said where we were coming from in our ASP.Net development experience. Then D’Arcy showed us how he typically structures his webforms applications, and we peppered him with questions.  I learned a lot from the session.

My talk was the second of the day in the large seminar room so we actually had about 50 people in the session.  One thing that was cool was that D’Arcy Lussier did an intro talk right before mine, so I got to build off of what he did in the session before. Mine seemed to go pretty well. There were a lot of questions and interest in what MVC brings to web development in the Microsoft space.

Jason Bock did a great job again bringing this all together.  It’s a lot of work coordinating an event like this.

If you liked what you got at the Twin Cities Code Camp you’ll definitely want to check out the Iowa Code Camp.  We’ll be a little bit smaller, but have some top notch presenters, a great facility and will have great prizes as well.  The registration is right on the home page and is as simple as it gets.

Written by Chris Sutton

April 6, 2008 at 9:27 pm

PowerShell File Search

with 4 comments

If you are looking for a file or directory in your file system try something simple like this:

dir -recurse -filter *power* | sort name | ft directory, name

dir is an alias to the Get-ChildItem cmdlet – it does pretty much what it did in the DOS world (and more). The -recurse parameter looks in subdirectories as you might expect. -filter lets you pass in a file or directory name or pattern. sort name … well you can figure this out.  ft directory, name is an alias to the Format-Table cmdlet and it lets you decide what columns you want in the table that gets outputted.

Here is a slightly more powerful expression:

dir -recurse | ?{$_.name -match “^*.jpg|gif$”} | sort name | ft directory, name

With this expression you can do comparisons on specific fields. Here I’m doing a regex pattern match for all files that end with jpg or gif. ? is an alias to the Where-Object cmdlet. where is also an alias to Where-Object and might be more readable than ?.

Written by Chris Sutton

April 1, 2008 at 7:49 pm

Posted in Technology

Tagged with , ,

PowerShell Hex to Char

with 4 comments

Rob Conery posted a poem in hex on Friday and since I’m playing with PowerShell quite a bit, I decided to convert it back to readable English with some PowerShell.

First, I copied and pasted the hex characters into a text file and saved it as message.txt.

Next, I needed to load the file into a PowerShell variable so I could manipulate it. I’m issued the command in the same directory where message.txt is located.

$m = gc message.txt

Explanation: PowerShell variables are always prefixed with a $ symbol so in this case $m is going to hold the contents of message.txt.  gc is an alias to the Get-Content cmdlet which literally get the contents of a file.

Next, we build up the actual statement to convert the hex values to decimal and then decimal values to a characters.

$m.Split() | % {[Convert]::ToInt32($_,16)} | %{[Convert]::ToChar($_)}

.Net Type Explanation: $m is a string type at this point. You can verify it by issuing this statement – $m.GetType().FullName – and you will get System.String back. PowerShell is built on top of the .Net type system so you have access to all of the same objects and members as you do in C# or VB.Net.  $m.Split() is going to give back an array of strings.

Pipeline Explanation: You can’t go very far in PowerShell without encountering the pipeline. The statement above you read from left to right, and you use the | symbol to separate the statement into three distinct sections. The first section makes an array of strings from the original data.  The second section converts each hex value to an integer and the third section changes the decimal value to a readable character.  Each section of the pipeline gets processed and then the results of the current section get passed to the section to its right so it can do a new set of operations.

% Explanation: The % symbol is an alias to the ForEach-Object cmdlet. It is also aliased as foreach. % is usually going to be paired with a block {} that will be repeated for each item in a list/collection/array.

$_ Explanation: $_ is a variable reference to the current item in the foreach operation.

[Convert] Explanation: Square brackets around a word like [Convert] say that you are invoking a preexisting .Net type called Convert. If you were writing a C# or VB.Net app you could easily call Convert.ToInt32(“32”) and it would convert the string representation to an integer type.  So here, [Convert].ToInt32($_, 16) is an overload of the ToInt32 function that takes a string representation of a hex value and converts it to an integer.

:: Explanation: The :: operator lets you invoke a method or property on a .Net Type, hence we have [Convert]::ToInt32($_,16)

You have to read this poem vertically at this point, but you can do the work to fix that. I’m almost sure there are probably some ways to simplify this expression as well, so feel free to post comments on improvements you would make. This has become a much longer post than I originally intended, but before I sign off here is what the fully qualified expression would look like:

$m.Split() | ForEach-Object {[Convert]::ToInt32($_,16)} | ForEach-Object {[Convert]::ToChar($_)}

Written by Chris Sutton

March 30, 2008 at 2:36 pm

Posted in Technology

Tagged with , , , ,

PowerShell left hand rule

with one comment

PowerShell uses the “left hand” rule when deciding how to interpret operators. Meaning that the type of the value on the left side of the operator is dominant. Here are some examples:

2+2  (gives 4)

2+”2″  (gives 4)

“2” + 2  (gives “22”, string data type wins out using + for concatenation)

“2” + 5  (gives “25”, concatenation again)

To have a little more fun try some multiplication:

3 * 3 (gives 9, ok this is still boring)

4 * “5”  (gives 20, the “5” becomes an integer)

“3” * 4 (gives “3333”, that’s more interesting, “3” means the string data type is the primary type, this acts much like Ruby)

Here is a bit more that might be interesting:

15,30,45 + 3  (gives a new list of 15,30,45,5)

15,30,45 * 3  (gives a new list of 15,30,45,15,30,45,15,30,45)

Kind of cool how this works.  The DOS prompt was stone-age comparatively.

Written by Chris Sutton

March 27, 2008 at 6:31 pm

Posted in Learning, Technology, Thoughts

Tagged with , , ,

PowerShell del

with 2 comments

del is an alias to the Remove-Item cmdlet and you can use it pretty much like you did in a DOS shell. But there are some additions.  It can delete more than just files and directories. It can now delete certificates, registry keys, aliases and more.

One of the nicest features is that you can issue a del command with the -whatif parameter and it won’t run the command, but will tell you what would be deleted if you really did issue the command. So del *.zip -whatif would give you a list of .zip files in your current directory, but wouldn’t actually delete them.

If you haven’t tried PowerShell yet and you work from the command line a lot, you really should check it out.  It is a pretty easy transition from cmd.exe, but there is way more power under the hood if you want to dig deeper.

I’ll likely blog more on PowerShell in the future and will link to many of the resources out on the web to help you learn how to use it.

Written by Chris Sutton

March 26, 2008 at 7:39 am

Posted in Learning, Technology

Tagged with , , ,

Source Control Thoughts

leave a comment »

I was catching up on some ALT.Net reading on the Yahoo Group and came across this gem on a thread talking about people’s favorite version control:

I was informed recently that I may have to contribute to a project that’s using VSS… I immediately thought of this quote about VSS by a MS employee “Visual Source Safe? You’re better off printing out your code, putting it through a shredder, and lighting it on fire.”

Just to be fair, if you have your source stored in Visual Source Safe, that is better than nothing. But you can do much better with little effort.

VSS still doesn’t have atomic commits to the best of my knowledge.  What other kind of database that stores information as critical as your source is allowed to get away with non-atomic commits?

If you have had your source stored in VSS for at least a year and you are the admin, how many times have you had to run the database analyzer? And how many times has it told you that your repository or a block of files have been corrupted?  If your repository has been corrupted at least once, you should have red flags all over the place.

Think of this in terms of your regular databases.  If your SQL Server/Oracle/MySQL databases frequently gave you “your database has been corrupted” messages would you keep using that database?

So once again, you can do better. Here are two good options – there are many more.

I think the easiest sell is using a tool like Subversion.  It is a stable and widely used repository.  There are excellent client and admin tools available for many platforms.  I have used Subversion off and on for the last 4 years and heavily for the last 2 years and have been very pleased with it.  It is stable, reliable, accessible and it is actively being improved and developed.

If you are a larger company in the Microsoft space and you have plenty of money budgeted for your source control strategy you might look at Team Foundation Server. I’m using this on an open source project and have been satisfied with its performance and usability. My only gripe so far is that it does poorly in a disconnected scenario – Subversion really shines here.

Written by Chris Sutton

March 25, 2008 at 8:42 am

FolderShare is apparently still alive

with one comment

I’ve been using FolderShare for 2-3 years and it has been solid as a rock for that time. I don’t think it has gotten a single update since I began using it. Anyway, last week it received an update. To be honest it looks like the update brought us a new version number, a new program icon and a revised site.  I can’t find any new functionality, so it seems the purpose of this update was to bring it more into line with the Windows Live branding.

At least it is showing signs of life though.  The next killer feature would be to build a client for Linux. I’d really like to be able to synch over to some Ubuntu machines. I’m not holding my breath though.

Written by Chris Sutton

March 14, 2008 at 2:22 pm

Posted in Technology

Tagged with

Cedar Rapids 2008 Launch Event

leave a comment »

This Monday, March 17th, is our CRIneta.org Visual Studio/SQL Server 2008 Launch Event.  If you want to learn about the new products and you want to have a great time and win from a huge pool of excellent prizes, then go to CRIneta.org and RSVP to be a part of this event.

Tim Barcz, Greg Sohl, Arian Kulp and I are presenting sessions on Visual Studio enhancements, Linq, IIS 7, C# 3, the new .Net Framework features and the new SQL data types.

We have room for 50 people and 38 are RSVP’d already, so don’t wait too long. We are doing the Launch at the Marriott on Collins road in Cedar Rapids. Check the website for more details.

Written by Chris Sutton

March 13, 2008 at 9:18 pm