patterns-and-practices

What is the best practice to create an ASP.NET portal and modules?

Recently, our development team was approached by a representative from one of the departments at our institution looking for a web based solution to help out with their workflow. A few weeks later, another person from that department approached us concerning another solution for a completely different workflow process. Then after that .....

Good practices for building web application that can later have and mobile(Android/iPhone) version

Hi, can you advice me a book or something else containing good practices about how to build/structure a web application in a way that will be easy to extend it with an Android/iPhone version later. I am currently trying to get into Django so it will be nice if the practices are related to it, but every hint will be appreciated. ...

Is it better to have a method's datatype be as specific as possible or more general?

In ASP.Net MVC if I have a method on a controller that returns a View should that method be of type ViewResult or the more general ActionResult? ...

Whats better design/practice: Nullable property or 1 value property and 1 bool "has" property?

I'm working on an ASP.NET MVC app, designing the domain models, using (testing) the new EF Code First feature. I have an Activity entity that may or may not have a Deadline, what is the best way to approach it? 1 property: public DateTime? Deadline {get; set;} and check vs null before using or 2 properties: public DateTime Deadl...

Ways to handling huge transactions on any database?

I have a data transformation product, which lets one select tables in a database and transform row data in the source database to a destination database. This is handled in the current product (java based workbench and engine) by processing 1000 rows at a time and doing it 10 threads parallely. This approach works fine on smaller data ...

Am I breaking the "Law of Demeter"?

I just recently became aware of the Law of Demeter. Like a lot of things, I realized that it was something that I was already doing but did not have a name for. There are a few places though that I seem to violate it. For example... I might have an Address object: public class Address : IAddress { public string StreetAddress { ge...

Is my singleton design less elegant than it should be? What's the best practice?

I'm currently building a tool for my game engine using WPF. The tool is project-centric (think Visual Studio, XCode, etc.) and allows the user to edit one project at a time. Currently, my implementation hosts a singleton instance of the project class, ArchitectProject. This is available to all other components as a property on the singl...

OOP, protected vs public. When to use?

Im trying to understand the benefits of making a class variable private, versus public. I understand getters / setters to access / modify the private / protected data, but is its sole purpose is to 'keep me from mangling my data'? Example : I dont get how saying $person->age = x;//bad? has different potential for havoc than $person-...

Return Null or throw Exception in retrieval method?

Possible Duplicate: Return 'null' or throw exception Say I have a method public Person LoadPersonFromDatastore(int personId) { ... } What should I do if the person was not found? Is it best to return null or should I throw an Exception? My opinion would be not to use an exception here since it adds no useful information i...

Is it always a good practice to use aliases in sql joins or nested queries?

Is it always a best practice to use - Select E.Id,D.DeptName from Employee E join Dept D on E.DeptId=D.Id instead of - Select Employee.Id,Dept.DeptName from Employee join Dept on Employee.DeptId=Dept.Id Other than readability and reducing length of the query what are benefits of using aliases ? When I consulted with our Database ex...

what is the recommended approach for application settings in RoR?

i'm a .net guy doing some work/learning RoR. i have a handful of environment-specific settings i'd like to externalize (s3 access info). what is the way to do this? I realize the place for it is in config/environment/[environment], but i'm asking beyond that. Should it be a global constant? should i use an initializer? how do i cleanly m...

Is it bad practice for a child object to have a pointer to its parent?

In a C++ application, let's say I have a window class, which has several instances of a control class. If my window wanted to notify a control that it had been clicked, I might use: control[n]->onClick(); Now let's say that the control needs to know the size of it's parent window, or some other information. For this I was considering ...

Best practise with handling password via Web service

I have N- Tier application Which consist of three parts: 1. Client (WPF) 2. WebService (Java web service) (Business logic) 3. Database (Oracle) I store my password in md5 in oracle database but send password from from client to web service in not encrypted state just like a simple string. Which technic I have to use to secure password...

Good Reusable, centralized AJAX component based on jQuery

I ofetn find myself writing the same code in jquery for ajax stuff. Still i can't find a good Reusable, centralized AJAX component based on jQuery... Note: One similar question i had asked before Reusable jquery ajax requests but it had some issues. ...

Mysql: limits on table count, rows, and such

I'm working on a social network. From what I've gathered, there's a limit at 1792 for number of tables in a mysql cluster. I will probably end up with 100-200 tables for now. Is this reasonable/acceptable? Or is my db schema horrible like this? What is reasonable for a large scale project such as a social network? Also, what then is t...

In which scenarios do you use encapsulation?

I would like to know in what scenarios you use encapsulation. The purpose of this question is collaborative. So feel free to share your own experience when the subject is encapsulation. Some scenarios: Calculated property public class Order { private List<ListItem> listItems = new ArrayList<ListItem>(); public double getTota...

Is this an Exception Handling abuse?

I have this method, that can return three different response. At first, it was supposed just only return two, so I make its return type to Boolean like: public static boolean isLoteWaitingForImage() And some business logic came out with that it can has another result, so the method was modified to public static boolean isLoteWaitin...

Avoiding repetition when using callback functions and asynchronous requests

I am writing some Javascript/jQuery code that requires me to make lots of requests to various APIs. I have come across this problem many times and this is just a basic example of one instance of it. The code makes an asynchronous request to a server and then if a condition with the returned data is not met, the code makes another reque...

Is it "a-must" to trim all whitespaces in POST/GET vars?

IMHO, I heard about this few times lately. On some web portals I saw when whitespace in the beginning of the keywords, returns empty search result, without whitespaces it's working. Are there some cases when this can be harmful? Can somebody give an arguments for this kind of practice? ...

Creating a subversion repository for website.

What is the best practice for creating a website repository? Is the repository the live on the and does not require moving files from the repo? Or do you need to move files from the server repository to the web server? ...