Thursday, April 11, 2013

Test Driven Development


It is pretty hard writing an article on something that so many super cool authors have written books about. But, as I said it is my own experience learning and embracing TDD that I want to share here so that maybe I can help someone out there that can relate to this. And also I can always remind myself of the process I went through while learning it.
Bottom line is that nobody can teach you a programming approach like this by writing or making videos about it. They can only get you started and they can tell you why you should do it. The real power comes by you actually digging into it. The more you do it the more you master it and the more you can actually feel the benefits of it. I didn’t believe when people said it was addictive, in matter of fact I opposed to the whole idea. I was one of the people that thought this is a waste of time and that you can achieve more by just writing production code….and boy….was I wrong about it.
We have to start somewhere, so why not at the very core of it. The unit test definition.

Monday, January 14, 2013

New Beginnings


Well, it’s been quite intense last few months and thus not so much time to write blogs. Intense but in a good way I must admit. I changed my workplace, I changed the country I live in even, but all for a good cause of helping the world become a better place (sometimes not sure if that last thing is the complete opposite or not, but, that’s for others to say).

Sunday, May 6, 2012

The S.O.L.I.D. Design Principles

The S.O.L.I.D. Design Principles
There have been many questions I encountered lately of what are the best practices/guidances that you can take up on when designing an application.
Wheather that's an ASP.NET application or any other type of application that uses object oriented principles.
First and upmost, let me begin with probably one of the most important principles in object-oriented development and design, and that is the Separation of Concerns(SoC) principle.

Separation of Concerns (SoC)

SoC is the process of dissecting a piece of software into distinct features that encapsulate unique behavior and data that can be used by other classes. Generally, a concern represents a feature or behavior of a class. The act of separating a program into discrete responsibilities significantly increases code reuse, maintenance, and testability. Like, for example MVC can separate content from presentation and data-processing (model) from content.

Of course, every programming language has it's own ways to incorporate this principle in it's own ways.


The S.O.L.I.D. Design Principles


S.O.L.I.D. (stands for Single responsibility, Open-closed, Liskov substitution, Interface segregation and Dependency inversion).
The S.O.L.I.D. design principles are a collection of best practices for object-oriented design. All of the generally known Gang of Four design patterns adhere to these principles in one form or another. The term S.O.L.I.D. comes from the initial letter of each of the five principles that were first collected in the book Agile Principles, Patterns, and Practices in C# by Robert C. Martin. Commonly known to us as "Uncle Bob"
The following sections describes each one of them.

Wednesday, March 28, 2012

I’m a Junior Developer – You probably are too - Diary Of A Ninja

Here is an interesting article I read the other day:

I’m a Junior Developer – You probably are too - Diary Of A Ninja

Kind of makes you think that at some point we have to realize where we truly stand and how good we are.

Social networking(for developers) in the likes of blogs, stackoverflow, github, twitter etc. these days helps us achieving that by helping us putting ourselves "on the map" and try ourselves out in the real world....out of the comfort of our own basement where we actually think of ourselves as being REALLY good.

Scott Hanselman actually talks about a lot of this social networking aspect of things in hanselminutes. I suggest that anyone interested takes a look at it.

While we're at it...feel free to follow me on twitter....@bojanskr.

Cheers,
Bojan

Monday, March 5, 2012

Providing a File for Download trough a Save As Dialog in ASP.NET


The question of providing a file trough a SaveAs dialog in a web browser appears very often in the forums and QA websites like Stackoverflow.
The default action of the web browser when a file is provided is to open it. It automatically determines the file type and opens it inside the browser. An example would be a link to a .pdf, an excel or image file etc. When you click on it it opens the file in another tab or another page.

You have two options to achieve this depending whether you are using an already existing file or you are dynamically generating it(or getting it from a database or such).

Saturday, February 4, 2012

Using a .NET assembly in SQL Server 2008


Many times you fnd yourself in a situation where you have to do something that seems too complex to implement in TSQL or you just want to use some feature from the .NET framework, or you already have something implemented in an assembly and you want to use it in your stored procedure or function. While TSQL is very powerfull and there are lots of things you can accomplish the answer to the above is to just use a .NET assembly in your TSQL code.

Monday, December 19, 2011

Custom Membership User

Custom Membership User

Hello again. In the first part of these mini series we discussed how you can create a custom membership provider and a custom role provider.
Many times you will find yourself in a situation where you need to store and retrieve more data for a specific user than it is available in the  MembershipUser class, which is the default for a MembershipProvider. While there is a way to acomplish this by using profiles and the ProfileProvider class here I will show you how to accomplish this by creating a custom membership user.

Thursday, December 8, 2011

Custom Role Provider

Custom Role Provider

In the first part of these series we discussed and provided an example of how to create a custom membership provider. We will continue these mini series with a discussion and an example of how to create a custom role provider.
We said in the first part that the reason of why you would like to create a custom membership provider would be if you want to use a data source different than the one supported or if you need to manage role information using a database schema that is different from the database schema used by the providers that ship with the .NET Framework. The reasons of why you would want to create a ciustom role provider are the same.
In the example that I'm going to provide I use Linq-to-SQL data source and my own table structure to keep membership/user and role data.

Monday, December 5, 2011

Custom Membership Provider

Custom Membership Provider

Custom Membership, Role Providers, Membership User Series.

 Since I noticed that this articles and the examples in them are pretty long, it could get pretty cumbersome to have all of them in one go so I split them up in several articles. Here goes the first one.

Custom Membership Provider

There are many times when the MembershipProvider and its underlying database construction aren’t sufficient enough for our needs. As MSDN states there are two reasons why one would want a custom MembersipProvider:
  • You need to store membership information in a data source that is not supported by the membership providers included with the .NET Framework, such as a FoxPro database, an Oracle database, or other data sources.
  • You need to manage membership information using a database schema that is different from the database schema used by the providers that ship with the .NET Framework. A common example of this would be membership data that already exists in a SQL Server database for a company or Web site.

Monday, November 21, 2011

FileUpload Control in ASP.NET and IIS7

When you want to work with the FileUpload control in ASP.NET probably the most important thing to have in mind is that you are working with files, and files can get big, sometimes really big. By default with the FIleUpload control you can upload files that are 4096 KB (4 MB) in size.
Of course, you can override this setting by changing the httpRuntime maxRequestLegth in web.config file of machine.config file (if you wan't to override the setting on the whole computer for every application etc.). For example:


<system.web>
   <httpRuntime maxRequestLength="2097151" enable="true" />
</system.web>

(remember that the size is in kilobytes, so this is sround 2GB)
Now, this is all fine. You change it, you test it locally and it all works fine. At least that's what I did. I even hosted it on the local IIS....Untill....
I published the application to a server that had IIS7 installed on it and I started getting a 404 Error. It was very frustrating really. Then I went trough the Microsoft documentation and found out that things are different on IIS7. There's a completely different setting called maxAllowedContentLength under requestLimits under security. Example:

<security>
   <requestFiltering>
     <requestLimits maxAllowedContentLength="2097151" />
   </requestFiltering>
</security>


Turns out that requestLimits is far more than just limiting the size of the files. Here's a link for those who want to dig a little deeper on the issue:

http://www.iis.net/ConfigReference/system.webServer/security/requestFiltering/requestLimits


Hope this helps someone,

Bojan