Tag Archives: development

Patterns and Practices: Dependency Injection 101

0
Filed under .NET, Productivity, Software Architecture

This is the start of a series of posts that I’ll be doing on design patterns and best practices; it involves the use of common development concepts that I find a core part of development.  If your interested in following, they will be under the category ‘Patterns and Practices’.

One of the most common patterns seen in ASP.NET MVC is dependency injection (otherwise known as Inversion of Control).  Why? It loosely couples the parts of the application and really emphasizes the ability to unit test the separate layers of your application.  Why is unit testing important? Unit Testing, while it may add more time to your development, it allows developers, testers and the client to feel more confident that their code is doing what it is supposed to do.

So what exactly is dependency injection?  Many of us use patterns without even knowing that we are doing it, so this may sound familiar.  It’s actually pretty straightforward, using an instance of one class, it calls an instance of another class, but not by a concrete implementation, but rather by interface.  In essence, dependency injection, aims to reduce the amount of boilerplate wiring and infrastructure code that you must write and implement one of the core design principles, code to an interface not a implementation.

Here’s a simple example, the AccountService has to get a Account.   It looks like this:

public class AccountService
{
  private IAccountRepository _accountRepository;
  public AccountService(IAccountRepository accountRepo)
  {
    _accountRepository = accountRepo;
  }

  public Account GetAccount(int accountId)
  {
    return _accountRepository.GetAccountById(accountId);
  }
}

When we need the AccountRepository, we ask the dependency container to get it for us the instance based on what it’s mapped too.  Why does this benefit developers? It’s good because the AccountService doesn’t know or care about it gets an Account.  You can stub out what the methods and properties on a fake IAccountRepository might return, and test just the AccountService.  You can also use this to change the implementation of the IAccountRepository on the fly based on the type of storage you may be using.  Coupled with a framework such as Ninject, using dependency injection is a powerful pattern that should be used more often.  In one of my following posts I’ll go into using an example of using Ninject and a basic tutorial.

Article source: http://robbiemadan.com/2012/05/09/patterns-and-practices-dependency-injection-101/

Microsoft LightSwitch – Sending Emails From the Client

Comments Off
Filed under .NET, LightSwitch, Productivity

Most of you may have already read an earlier post on how to send emails from LightSwitch (seen here). This post extends what was learned in that previous post, and shows how to wire up a button to send an email on demand.That previous post showed a specific function that would send out an email when an entity was added to the database. A helper class was created in the Server project of the LightSwitch solution. Then, when the new record was created in the database, that server code was called and an email went out. Here is how  I did that… Read More »

Article source: http://www.paulspatterson.com/technology/lightswitch/microsoft-lightswitch-sending-emails-from-the-client/

Microsoft LightSwitch – Championing the Citizen Developer

Comments Off
Filed under .NET, LightSwitch, Productivity

I recently watched a great webcast by Rich Dudley in which Rich made some very interesting points about what Gartner Research calls “Citizen Developers”. I was immediately intrigued by this Gartner information so I dug a little deeper into this citizen developer thing, and here is what I found…

According to Gartner, “Citizen developers will be building at least a quarter of new business applications by 2014…”.  That, according to the report titled “Citizen Developers Are Poised to Grow”.

Represented by about 6 million information workers, these “latent” application developers make up that same Microsoft Visual Studio LightSwitch target market.

Very interesting, indeed!

 

 

Article source: http://www.paulspatterson.com/technology/lightswitch/microsoft-lightswitch-championing-the-citizen-developer/

To be or not to be….Naked at work……

3
Filed under Corporate Culture

There has always been major controversy about how businesses should conduct themselves amongst employees, clients, and the public. Society is constantly changing and manifesting what they consider to be acceptable business practices. And through these ever-changing opinions, we change our views on the types of companies we want to do business with. And one of the more forward thinking ideas is that a business strategy and structure should be transparent, or naked to the public.

 Transparency by definition means capable of transmitting light so that objects or images can be seen as if there were no intervening material. So fine in texture that it can be seen through. (http://www.thefreedictionary.com/transparent)

 This nakedness/transparency when applied to business allows the public, clients and potential clients to get a very clear understanding of the business they are choosing to partner with, employ or engage. If a business is transparent studies have begun to show that it increases productivity and enhances the ethical workplace culture. One Study by Deloitte in October 2008 published: Read More »

An Introduction to LightSwitch – Edmonton Dot Net User Group Presentation – September 12, 2011

Comments Off
Filed under .NET, LightSwitch

On September 12th I presented an introduction to Microsoft Visual Studio LightSwitch 2011 to the Edmonton Dot Net User Group (EDMUG.Net).

Here is a link to the slide deck and take-away notes from the presentation…

http://www.paulspatterson.com/technology/dot-net-development/edmug-lightswitch-introduction/

Cheers!

 

Application Types

Comments Off
Filed under .NET, Software Architecture

Yes, a rich internet based web application would be awesome, but is it really what you need? I would love to own a new Porsche 911, but not if I am using it to haul around building supplies for my construction company (unless it was balsa wood, maybe).

Just like using the right vehicle for the job, so should you be using the right software application for the right job. Here is an overview of the different application types that exist today, and some information about each to help you better understand your options when considering a new software application… Read More »

Functional and Non-Functional Requirements

Comments Off
Filed under Software Architecture

There are actually methods to the madness in the process of gathering information for software requirements. As a system end-user or a subject matter expert  it is likely that you have worked with others during some information gathering processes. Whether it was via a big meeting, or a simple phone call, someone probably has asked you a question or two about what you want the system to be or do. To help you better understand what is being asked of you, here is an overview of the two types of requirements that you are being asked about… Read More »

I’ll be Speaking at EDMUG on September 12 2011

Comments Off
Filed under .NET, LightSwitch

On September 12, 2011 I’ll be speaking at the Edmonton .Net User Group (EDMUG). I’ll be presenting an overview of the recently released Microsoft Visual Studio LightSwitch 2011. RSVP via the EDMUG Meetup site at www.EDMUG.net.

EDMUG LOGO

Copyright 2011 by Quercus Solutions
Login