Category: .NET

Tiling a 2-D Polygon using C# GDI+

Tiling a Polygon

Tiling a Polygon

One of the most challenging problems I came across working on a .NET PDF Annotator and Editor application was to tile a 2-D polygon and also accurately determine the number of tiles that fill the surface of the polygon.  The tiling part was not as much of a challenge as the counting part. The tiled polygon was to be rendered on a PDF document since the application in question is a PDF Annotating and Editing tool. We looked for anything the third party .NET PDF rendering/manipulation API that was used could provide for the tile rendering but there was nothing unfortunately.
Continue reading »

C# Documentation (It ain’t that hard)

On a recent project after months and months and hundreds of files worth of work, we were asked to provide documentation for the code. This request could have gone one of two ways depending upon how well we adhered to some basic documentation rules.

The C# compiler itself is setup to extract documentation which can then be piped through one of a number of documentation generation apps. My preference is a new(ish) project called SandCastle from Microsoft, which aims to provide much of the featureset that NDoc once did. Unfortunately this application provides no GUI. A fine gentleman named Eric Woodruff stepped in to wrap this application in an easy to use GUI for us aptly named Sandcastle Help File Builder. Through the use of good comments written WHILE we wrote the code, we were able to pop out some documentation for every bit of code we wrote in a matter of minutes. Add to this the nice information we get when using our code via intellisense, and it simply doesn't make sense not to strictly enforce documentation standards on your project.

I often see code written with little or no attention paid to comments. Sometimes the comments are fairly haphazard and appear to follow no standards whatsoever. By following documentation standards, you too can auto generate documentation instead of wasting hours or days going back through and trying to remember what your code does. Continue reading »

OO Design Patterns that can make a difference

Design patterns. I think they are the one of the most intriguing areas of object oriented application design and development. There are so many out there that can puzzle you each and every time you try to take a crack at them (I can name a few of them that I still can't figure how they are to be used or implemented).  But a thing that most programmers would agree is if used wisely and appropriately, these design patterns can provide really powerful benefits that can enhance one's programming experience and also the software that is being built. There are several patterns I have used/implemented in my projects that I think are awesome. I ll touch upon how I used some of them and why every Object oriented programmer needs to master them.

Continue reading »

Topics: , ,

Launched: Vu360 PDF Annotation and Markup Application

Please install Flash to see this video player!

Vu360, the latest Pathfinder product, was launched by our client the Blue Book of Construction earlier last month.

It’s an Internet-tethered desktop application that enables easy viewing, markup and takeoff of PDF and TIFF documents for the architecture, engineering and construction industry. Some of the features include:
Continue reading »

UI Views – Include or Exclude from Code Coverage

My post today comes after watching the code coverage hover just over 70%, constantly asking myself is it possible to get

100% coverage and a discuss with a few internal colleagues on the subject. Interesting to know is if I exclude the views from code coverage,  I hit a high of just over 90%.  So, is not testing your UI the end of the world? Not at all, as long as you use good development practices and aim to make your UI as slim as possible, without any business processing, branching or conditional type logic.

I've been very pleased with using the PureMVC framework on my current project, and haven't running into any Ah! Ha! I gotcha scenarios yet and frankly can't envision any as we continue to add new features to this application.  In fact using PureMVC has helped me think more about testability of our code and its single messaging bus has been just what the doctor ordered in terms of eliminating Publishing/Subscribing to events between the various components of the system, namely Mediators, Proxies and Commands.  But with great power comes great responsibility.

One could easily access the Singleton Facade of the PureMVC framework directly from your view and send a system wide message to any component interested in that message. The problem here is testability of the UI event required to trigger that system notification.

For instance in the code snippet below you would have to create an instance of the UpgradeView and simulate a click of the download button in order to test sending this notification.
Continue reading »

More on Pure MVC for C#

puremvc

Last week, Karega Scott made a nice post on how Pure MVC makes development of Windows applications using C# simple. I thought I ll piggyback on this post and share some of my thoughts regarding this popular framework. I think the framework, if understood completely and adopted intelligently, has to offer some really cool benefits like :

  • Light-weight messaging mechanism (using Notification/Observer patterns) between different parts of the application without having to create custom events/hooks all over the place.
  • Highly Decoupled Components allowing abstraction and seperation of logic.
  • The application's testability is enhanced greatly because of the reason stated above.
  • A Centralized singleton Facade component that mediates between the different components in the application.
  • The use of commands in the framework can help in building complex applications that need to perform several different UI-driven functions.

Continue reading »

WinForms Development Made Simple with PureMVC

PureMVC is open source framework that allows creation of application using Model, View and Controller pattern, and was original designed for Flex, Air and Flash application. It has since been port to various languages include the .NET C# language. So when I first heard about it, several months ago, I was working on a pretty large WinForm application design around the MVP - Model, View and Presenter pattern.

Our presenters were responsible for handling the user interaction coming from the views by subscribing to events published by the views, and coordinating these actions with changes needs from the models such that these changes are then reflected back in the views themselves.

Although this approached work, it requires a lot of wiring and unwiring of events from the various presenters to views, presenters to model, and presenters to presenters. So the code quickly begins to look like the following:

public class presenter1

{

public event EventHandler<EventArgs> SomethingHappened;

public presenter1()

{

_model = new Model();

_model.StateChanged += OnModelChange;

_model.DocumentSaved += OnModelSaved;

_view = new View();

_view.OnMouseDown += OnMouseDown;

_view.OnMouseUp += OnMouseUp;

_view.OnMouseMove += OnMouseMove;

_view.OnMouseEnter += OnMouseEnter;

}

As you can see, for every user interaction on the view or model change a particular presenter is interested in, you must subscribe to an event, and if other presenters are interested in particular actions from views they are not responsible for, well, I’m sure you can get the picture. So act II, introduction of PureMVC framework for WinForms.

So exploring the capabilities of PureMVC framework, uncovered a simplification of our code. At its core, it consists of four singleton objects Model, View, Controller and Façade. The Model, View and Controller contain literal string references to Proxies which are data model, Mediators which provide and manage the user interface, and Commands which interact with the Proxies and Mediators or other commands.

But the simplification revolves around the Façade which is responsible to provide messaging throughout the core framework using an Observer notification scheme. So now our code quickly begins to look like the following:

public class presenter1 : Mediator

{

public presenter1()

{

}

public override void ListNotificationOfInterest()

{

return new List<string> { Nofication.ViewMouseClick, Notification.ModelChange,};

}

public override void HandleNofication(INofication notification)

{

switch(nofication.Name)

{

case Notification.ViewMouseClick:

Dosomething();

break;

}

}

public class presenter2 : Mediator

{

public presenter2()

{

}

public override void ListNotificationOfInterest()

{

return new List<string> { Nofication.ViewMouseClick,};

}

public override void HandleNofication(INofication notification)

{

switch(nofication.Name)

{

case Notification.ViewMouseClick:

DoSomethingFun();

break;

}

}

public partial class view1 : Page

{

protected void view_mouseclicked(object sender, MouseEventArgs e)

{

Façade.NotifyObserver(new PureMVC.Pattern.Notification(Notification.Name));

}

Both presenter1 and presenter2 state they are interested in Notication.MouseClick event, and view1 uses the Façade to notify both presenters that the user has clicked the mouse button. No need to publish and subscribe to any events outside what’s naturally needed in the view.

The only thing I dislike is the name references, but as long as we are using constants you should be fine.

Related Services: .Net Application Development, Custom Software Development

Fluently NHibernate

logo

Fluent NHibernate is an extension of the widely used and very popular NHibernate framework for Microsoft .NET. It is an open source framework that sits on top of the NHibernate layer and utilises all the core NHibernate methods. This framework provides an alternative to the standard XML based mappings (.hbm xml files) of NHibernate. It lets you define the NHibernate mappings in strongly typed and concise C# code.  For those who are new to NHibernate, here is more information.

Continue reading »

.NET Web Browser Control Gotchas

How many of you folks out there have used the .NET Web browser control for Windows applications? I bet most of you, at some point, must have done some head-scratching as to why Microsoft did not make this control as powerful as it should have been. This control does offer all of the navigation functions and basic browser capabilities but there is lot more that could have been done to enchance it's utility value. After some persistent fighting with this control in our current project, here are some gotchas that I have to offer.

Continue reading »

Database Migration Tools for .NET

For the past several months, I was working on a Windows desktop application that didn't require any connection to a database, and now that this project is coming to an end and my next assignment is Web application with database connection. I wanted to see what my options are for database migration tools. In the past I've used dbsetup.vbs script, created by Alek Davis, and although it worked it did require some modification to the underline script. So I'm currently looking at several alternatives that could serve as a suitable replacement.

RikMigrations
Migrator.NET
Subsonic Migrations
dbDeploy.NET

Here are some useful links I've found to help determine which toy, I mean, tool, I plan to use next.

http://www.infoq.com/news/2009/01/migrations_dotnet
http://flux88.com/blog/net-database-migration-tool-roundup/
http://alekdavis.blogspot.com/2008/07/database-installer-revised.html

Summer Software Development Internship

We're starting a software development summer internship in our Chicago office this year. If you're a college junior, senior or recent graduate who want to learn the agile/OO development ropes while developing really cool products and services and earning $20/hr per hour (you should pay for the privilege, right?), give the internship posting a look here.

Deploying .NET Windows applications

nsis

I m sure many of the .NET programmers who have worked on building .NET windows applications must have had a chance to play around with the MSI/Deployment Project. This is the built-in project that the framework offers to build installers for deploying and installing windows applications. I think this project provides decent capabilities for packaging and installing windows applications but definitely has some limitations.

Continue reading »

Before your Code Mildews — Refactor!

Squeeze?
Creative Commons License photo credit: erix!

In my last post, See the Code, Be the Code, I compared agile development to the game of golf. But how does one truly "see the code" as the software grows in size and complexity? On one hand, you could ignore the fact that software is developed over many iterations and try to build a very complex system all at once that does everything under the sun, or you can keep the design simple and focus on the iteration at hand knowing that as our understanding increases we will refactor the code.

Refactoring is the process by which you modify the behavior and appearance of the code to ensure that code is up-to-date with current system requirements or changes in the system environment. It gives the development team an opportunity to continuously improve code quality for long term readability and maintainability. The easier the code is to follow, the less time it will take for current and future development teams to make changes as the system matures. It can also help the development team take advantages of improvements to existing frameworks and other software used to develop the application. These improvements can be realized through better performance and reusability of existing and future code. In short, it helps keep your code from become stale and mildewy.
Continue reading »

Topics: ,

Category and UI changes on Pathfinder blogs

If you read one or more of the Pathfinder blogs in our web interface, you may have noticed some tweaks to our navigation and top-level categories. Our goal in making these changes was to help different audiences drill down to the specific content that interests them. Instead of just a few top-level categories, we now boast around 20, though many posts appear in multiple categories. To subscribe via RSS to any specific category - or to our entire feed - just visit our Feeds page.

Topics:

PureMVC, Spanning the Platform Spectrum?

PureMVCAt Pathfinder we do a fair amount of desktop style development -- iPhone/Cocoa, WebForms, Swing -- and web application development -- Grails, Rails, JSP, ASP.NET, etc., etc.. In the last two years we, like a lot of other software development shops, have experienced a convergence in our efforts. The web is coming to the desktop in the form of Air and the Desktop is coming to the web in the form of RIA's. Now web MVC, which used to be a pretty benign pattern mostly concerned with app flow and validation, is starting to resemble desktop MVC, which has to deal with document-centric models and long lived views and all of the plumbing that requires.

So we recently had a powwow between all the different parties to talk about MVC and this convergence. With the exception of the insufferable Mac and iPhone developers and their disgustingly mature Cocoa framework, we all agreed it would be nice to have an application level MVC framework for each platform. We also agreed that Swing is a great example of what happens when the vendor doesn't provide such a thing -- spaghetti code that relies on component level MVC and hard wiring at the application level. There are a few MVC frameworks for Swing, such as TikeSwing and Spring Rich Client (soon to be superseded by Spring Desktop), but for every Swing app that has this sort of design, there are hundreds that are just a mess.
Continue reading »

Launch: Pathfinder Newsletter

    Get a monthly update on best practices for delivering successful software.

    Subscribe via email


    Subscribe via RSS      RSS icon

Topics

Search

WordPress

Comments about this site: info@pathf.com