[AccessD] Primary keys and entry points (was: Learning .Net -- PHP Instead?)

Gustav Brock Gustav at cactus.dk
Wed Jun 24 16:47:46 CDT 2009


Hi Shamil

You may do so but why would you? If you don't have an Id as the primary key of the underlying table, you will have to construct one, and I just don't think it is worth wasting time on this when applying an Id resolves the task in a second. I even apply the Id to a table of countries because the ISO codes _may_ change (rarely I know) but - more importantly - I don't have to decide for using the alpha or the numeric ISO code as the key.

As for the single exit point, I don't think this a B/W discussion. Sometimes it is convenient to drop out at once when a simple condition is not met as in the example from the link:

    if (account == null) return;

at the top of a method.

However, I wouldn't put this somewhere many lines down as it is impossible to read; if you find such a line you will have to study every other part to look for similar lines. Thus, I much prefer the traditional construct:

    if (account != null)
        { 
          // 20 lines of code
          // (that are totally irrelevant if account is null)
          // later...
        }
    // and out we pop

This you can browse in a split second, and should you later need to apply some code for the case (account == null) it is very easy to insert that following an "else".

/gustav


>>> shamil at smsconsulting.spb.ru 24-06-2009 20:41 >>>
<<<
Natural PKs on the other hand...
;)
>>>
Hi John,

Do you mean "great PK debate"? :)

I feel that I will soon give up even "use Autonumber/Identity field for
every table" principle, which I do strictly follow for many years, in the
case ADO.NET Entity Framework will become my main Data Access/Manipulation
technology...

It's unbelievable...

--
Shamil


-----Original Message-----
From: accessd-bounces at databaseadvisors.com 
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of jwcolby
Sent: Wednesday, June 24, 2009 8:16 PM
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] Learning .Net -- PHP Instead?

And I contend that if the garbage collector is airtight then the need is less.

VBA OTOH has a garbage collector that belongs to a union, it only works on Mondays, Wednesdays, the 
third Fridays and never on holidays.  Unless of course it is just out on strike...

I think from reading the articles and the comments underneath that there is no consensus.  An 
opinion is an opinion is an opinion.  Man is a rationalization machine and while you can rationalize 
as many exit points as you want, I can rationalize only a single exit point.

Natural PKs on the other hand...

;)

John W. Colby
www.ColbyConsulting.com 


Shamil Salakhetdinov wrote:
> Hi Arthur and Charlotte,
> 
> I used to use the same "one exit point" principle over the years (especially
> in my VBA programming) but I must note it's becoming obsolete nowadays: I do
> not use it almost at all anymore in my C#/VB.NET development.
> 
> Have a look what is the reasoning behind this "new approach" to not bother
> about "one exit point" principle: 
> 
> http://ubuntuforums.org/showthread.php?t=631745 
> 
> http://discuss.joelonsoftware.com/default.asp?joel.3.325456.34 
> 
> Everything seems to be changing in programming these days but one who has
> been in programming for some time can rather clearly see we're "just"
> getting repeating/rethinking of "good old habits" but on higher current
> level of evolution spiral of computer science, programming methods and
> practices... 
> 
> Thank you.
> 
> --
> Shamil






More information about the AccessD mailing list