9.25.2012

How to get the address of the svn server for my subversion repository?


Recently, I had some code from a Subversion repository on my machine, but no longer had tortoise svn or any svn command lines tool set up.  Luckily, I remembered that in Subversion there is a lot of fun data inside the .svn directory.  For instance you can see the address of the server and repository by viewing the .svn/entries file at the root of the local subversion files.  Just look for the svn:// or svn+ssh://  

That line should show you the svn server address, as well as the repo name and branch.

9.18.2012

ASP.NET MVC Model binding in PHP?

I've been working a lot this year with ASP.NET MVC 3 and C#.  One of the things I really like about these technologies is the model binding.  Let's say I have a data model called "User", a plain old C# class like this:



I can set that as a model for my view to use in the "Edit" controller like so:




And then I have "User" as the data model in my view.  Here's what's awesome about it, let's say I need to accept edits of the user account, maybe they can fix their first or last name.  I can pass that same User model from the previous page via a form into an Edit method that accepts that data model.  I don't have to muck about with assigning the Request variables ( POST / GET ) to an object.  All that is handled for me.



The ASP.NET MVC model binding will attempt to bind your model in these scenarios:

- If you have a form element on the page with an idenitical name to a property in the model
- If the url contains a key value pair from your routing that is identical to a property in the model
- If any REQUEST element has a name that is identical to a property in the model
- Otherwise, that property of the model will remain null

Plus, the ASP.NET MVC model binding will let you turn on/off model binding for various properties of the model.

PHP, or rightly, the many PHP frameworks really need to implement something like this.  A few perform some pieces of this concept but I'm not aware of any that currently serve up the whole enchilada.  What do you think?


9.17.2012

Database stored procedures, functions and triggers are source code of your application. Please treat them as such.


As a consultant for the past two years, when I come into a batch of code that has many stored procedures or triggers in the database, the first thing I ask is whether those stored procedures and triggers are under some kind of revision or source code control.  If the developers/DBAs look at me like I've got two heads, then I know I'm in for a doozy of a gig because those devs are probably not doing the best job they could be doing.

And that makes sense right?  You don't call in a consultant if everything is unicorns and rainbows with your system.

Stored procedures, functions, and triggers in your database are part of your codebase.  They could even be the most important and most delicate piece of your codebase.

I'll repeat this again for total clarity... Stored procedures, functions, and triggers in your database are part of your codebase.

But not managing your codebase with a tool is a huge mistake.   And yet, I see this time and time again on my gigs.  And if I had a nickel for every time I saw a stored proc named with "_new" or "_new2" or "_use_this_one" in the name, I could invite Warren Buffet over to play cards and he would consider it.

For managing the source code of your stored procedures on SQL server, there's even some commerical tools available that take your database objects and chucks them into your source code repo.   Or you can always just create a "sql" directory in your source code repository and store the objects there.  

There are a lot of ways to manage this problem.  Ignoring it, is not managing the problem, it's making it worse.