|
|
This[^] might help.
"If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair.
nils illegitimus carborundum
me, me, me
|
|
|
|
|
These questions are more about validating how I create apps. I know how I like to do things, but I'm curious how the rest of you do it, so feel free to critique or post suggestions.
I created a playground WPF app for tracking projects. The purpose of this app is primarily to play around and learn. In it I have UI, Entities, DAL, and BL projects. In the DB I created Company, Client, and Project tables. The Projects table has FK's for 3 lookup tables. See the pic here[^]
My project entity looks like this
public class ProjectEntity : _EntityBase
{
public int ClientId { get; set; }
public int ProjectTypeId { get; set; }
public int ProjectStatusId { get; set; }
public int PayTypeId { get; set; }
public string ProjectName { get; set; }
public DateTime? EstStartDate { get; set; }
public DateTime? ActualStartDate { get; set; }
public DateTime? EstEndDate { get; set; }
public DateTime? ActualEndDate { get; set; }
public bool? IsActive { get; set; }
public decimal PayRate { get; set; }
}
Ok, now for the questions:
1) Would you have your entity objects maintain references to other entities, or just the PK? For example,
in the ProjectEntity I have ProjectTypeId which stores a reference to the Project Type row in lkpProjectTypes.
When I get a project entity, should I create and store a ProjectType entity on it, or just the PK?
What I usually do is store the PK of the lookup table, then call a method in the DL to get the lookup entity when
it's needed. But I could make the GetProject method in the DL create related object when its called. The
problem is that now you have a heavy object when you may not always need the child objects.
2) Similar to #1. When you create an instance of the ProjectEntity, would you create a ClientEntity and store it
on the ProjectEntity instance? If so, do you then go up the logical tree and create a CompanyEntity to store
on the ClientEntity which is stored on the ProjectEntity? Conversely, if you create a ClientEntity, do you store
a list of ProjectEntities on always? If all I want is to display the Client's name, then getting a fully loaded
ClientEntity seems like overkill.
3) How do you handle nulls, both in the DB and in the app? I'v heard some folks say never store nulls. I don't agree
with that, but I'd like to hear your thoughts.
Thanks
If it's not broken, fix it until it is
|
|
|
|
|
Kevin Marois wrote: 1) Would you have your entity objects maintain references to other entities, or just the PK? For example,
in the ProjectEntity I have ProjectTypeId which stores a reference to the Project Type row in lkpProjectTypes.
When I get a project entity, should I create and store a ProjectType entity on it, or just the PK?
I'm passing the integers around that represent the PK; a list of integers is simple, has little overhead and makes debugging easy. It's also not a large amount of "work" to fetch an ActiveRecord object based on it's handle .
Kevin Marois wrote: 2) Similar to #1. When you create an instance of the ProjectEntity, would you create a ClientEntity and store it on the ProjectEntity instance? If so, do you then go up the logical tree and create a CompanyEntity to store on the ClientEntity which is stored on the ProjectEntity? Conversely, if you create a ClientEntity, do you store a list of ProjectEntities on always? If all I want is to display the Client's name, then getting a fully loaded ClientEntity seems like overkill.
It would add some complexity to ensure that you don't waste too much resources. I do not see many additional benefits to this approach though.
Kevin Marois wrote: 3) How do you handle nulls, both in the DB and in the app? I'v heard some folks say never store nulls. I don't agree with that, but I'd like to hear your thoughts.
I think people should use arguments to defend their one-liners. It is said that a normalized database does not allow for "empty" values; on the other hand, the database-server provides you with the option. In practice, it's easier (and cleaner) to have a nullable field, than it is to have a new set of facts.
Bastard Programmer from Hell
|
|
|
|
|
Kevin Marois wrote: Would you have your entity objects maintain references to other entities, or
just the PK?
Depends on the nature of the objects and how they are used in the rest of the code.
Kevin Marois wrote: The problem is that now you have a heavy object when you may not always need
the child objects.
Yes that is the problem.
First however it must in fact be 'heavy' in terms of the production system.
So 10 rows isn't 'heavy' but one million certainly is. And if a sub entity represents 100 meg of data then even 10 of them is too many. But for the one million case it would always need to do a deferred look up.
For larger ranges with more moderately sized (much smaller sub entities) it depends on actual data and how it will be used.
Kevin Marois wrote: When you create an instance of the ProjectEntity, would you create a
ClientEntity and store it on the ProjectEntity instance? If so, do you then
go up the logical tree and create a CompanyEntity to store on the
ClientEntity which is stored on the ProjectEntity?
That question doesn't make much sense to me. A 'company' seems likes an owner. You can't create an owned object until you create the owner. And you shouldn't even allow for that possibility. Thus in the GUI the user must select a 'company' before doing anything with a owned object.
Kevin Marois wrote: 3) How do you handle nulls, both in the DB and in the app
I handle them as nulls. Presumably for the "app" you mean in the data object. If you mean system wide then the question is wrong because they way a business object deals with nulls is different than how the GUI deals with them.
|
|
|
|
|
I'm curious what people are using for application security in WPF/Windows apps? I personally don't like the .Net Framework Security. I have rolled my own user/rights tables and associated code.
If it's not broken, fix it until it is
|
|
|
|
|
Kevin Marois wrote: I'm curious what people are using for application security in WPF/Windows apps? I personally don't like the .Net Framework Security.
I'm relying on Active Directory; has little to do with likings, I'm simply outsourcing that part of the development to Microsoft
Bastard Programmer from Hell
|
|
|
|
|
I am doing a project title "Evaluating the efficacy of FEC coding in Network packet loss" I need report and code for this project..
|
|
|
|
|
This is really not a valid question. You cannot just post the title of your thesis and expect someone to provide the complete solution for you. If you cannot make the effort to do your own work then you cannot reasonably expect anyone else to do it for you?
|
|
|
|
|
Basavaraj Neelagund wrote: need report and code for this project..
Steps to achieve that.
1. Research the topic.
2. Learn to code
3. Write the code
4. test the code
5. Write the report (presuming that is different than the code.)
|
|
|
|
|
FEC in network packet loss? ...packets use CRC checks to determine errors, then retransmit when detected... are you sure your report even makes sense? 
|
|
|
|
|
and I need money; you give me money and I'll tell you where to find what you want.
"If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair.
nils illegitimus carborundum
me, me, me
|
|
|
|
|
You don't seem to want to do much work. Let me introduce you to my friend Google. [^]
|
|
|
|
|
Your link is broken... It seems we can't meet your friend...

|
|
|
|
|
Odd. Works for me. No, don't tell me it's an invisible friend.
|
|
|
|
|
wizardzz wrote: No, don't tell me it's an invisible friend.
Does this friend talk to you and tell you to do bad things to other people? 
|
|
|
|
|
My real friends do enough of that.
|
|
|
|
|
Let me be honest here. I am quite rusty having not done any development work for past year. Now, I am planning to create a WCF service based application. I am planning to go for a basic 3-tier architecture and using LINQ2SQL in the background.
I need to know the following:
1. How good is LINQ2SQL provided that I use the objects carefully and dispose them as soon as they are out of use? Is it good enough when we have large number of joins and sometimes, image and file streaming involved?
2. I know I do not need this but how easy or difficult it will be to move to a new database provider if I use LINQ2SQL? Is IOC a better choice?
3. If I go for IOC, has MS done anything good with Enterprise Library recently? I have used V4 and V3 and I didn't quite liked it.
"The worst code you'll come across is code you wrote last year.", wizardzz[ ^]
|
|
|
|
|
Look at Castle. It provides an excellent container, WcfFacility and ActiveRecord.
http://docs.castleproject.org/[^]
ed
~"Watch your thoughts; they become your words. Watch your words they become your actions.
Watch your actions; they become your habits. Watch your habits; they become your character.
Watch your character; it becomes your destiny."
-Frank Outlaw.
|
|
|
|
|
(if you can suggest a better subjet text...)
In Windows Explorer when you copy/paste a file in a folder you will have something like:
test.txt
test - Copy.txt
test - Copy (2).txt
test - Copy (3).txt
...
and if you copy/paste
test.txt
test - Copy.txt
test - Copy - Copy.txt
test - Copy - Copy (2).txt
Is there a known (described in the Windows UI guideline) algorithm for that?
Is it simple brute force search for the "next valid" name ?
Thanks.
Max.
Watched code never compiles.
modified 25-May-12 15:41pm.
|
|
|
|
|
Why don't you name them TWINS
Jago
|
|
|
|
|
Huh?
Watched code never compiles.
|
|
|
|
|
The way that Windows names files on clash depends on your Windows version. Easiest way to duplicate this is by getting the filename, and checking if there's an entry in the same directory with that constant attached;
SomeDocument.docx
OtherFile.txt
Dialogs.bin
SomeDocument - Copy.docx
Desktop.ini
Iterate the files, check for the constant - and add 1 to the value if appropriate. AFAIK, there's no existing API that does this for you. If there is, I definitely like to know
Bastard Programmer from Hell
|
|
|
|
|
Yeah, that's what I tought.
Thanks.
Watched code never compiles.
|
|
|
|
|
I was wondering if there are any design patterns in object oriented programming that address cross cutting concerns, i.e. I'm looking for approaches that don't involve an aspect oriented language (or AOP features added to an existing OOP language).
The closest I've come to so far is the decorator pattern. Say you have a class with a method called doIt. You want to log (a classic cross cutting concern) the results of this method, so you create a decorator class to wrap the original class. Inside its doIt method, it logs the results returned from the object it's decorating.
Thoughts?
|
|
|
|