Due to technical reasons in last 2 weeks i have no time and possibilities to write and post new articles. But now everything is ok and I hope that in the short time I’ll post something interesting.
Hard’n’heavy!
Due to technical reasons in last 2 weeks i have no time and possibilities to write and post new articles. But now everything is ok and I hope that in the short time I’ll post something interesting.
Hard’n’heavy!
As the result of previous parts we have domain with core classes and services. Actually we can generate and process any amount of data with methods provided by domain services. But there are some issues:
Domain by nature and the general plan must be absolutely independent and free from technology aspects as GUI/user interaction (WPF, WinForms, Web) and the data layer implementation (MSSQL, MySQL, Oracle, etc.)
Step by step we realize that application should be multi layered. And there are minimum possible set of layers, as I see it:
Now when we know layers responsibilities, next goal is to understand how they interconnect with each other.
So we have domain classes with minimal set of properties and methods. Also we have several tests on these classes. The goal is to learn how deal with domain classes – i.e. write services which will do complex calculations and modifications. For example count students in selected course.
Assume that one of the tasks is count classes for selected course and how many students in them.
Let’s think which domain classes known about each other:
I think it will be enough for now. What is the easiest way that will implement most of novice? Add to “School” method:
public int CountStudent(int classNumber) { … }
But it is a bad idea because of next reasons:
Article is a simple presentation of DDD and TDD in order to show how to deal with it and give an opportunity to start development according describing techniques. Those who already practice TDD and DDD, please don’t be strict to words.
DDD – Domain Driven Design, in few words it is a solution code manner. And your target is an extract main application logic, the core, in a separate independent module. Domain must be independent from specific technologies, it won’t relay on underlying data, graphical presentation and so on.
TDD – Test Driven Design, developing application by tests. “Test become before code”.
Both of these practices (maybe better to call it philosophy) come together in my projects and, to be honest, for me it’s hard to imagine their usage separately. But yes, you can use them absolutely separate and no one oblige you to apply them in every project together.
There is a dozen of books, articles and other stuff in any format and size. Somewhere it is simpler, somewhere with more complex vision. I wouldn’t like to make a historical excursion how DDD and TDD have been invented, because it’s easy to find out in web, to google Eric Evance books or visit Martin Fowler site. I’d like to share my vision of subject in simple words. Tell how it helps, works, evolves and supports. I hope I can achieve the goal.
Okay, let’s take a closer tour by these techniques.
During everyday work I create a dozen of custom control. Formally, every “User Control” is a custom control. I create a specific layout from standard controls and use it in a program. I don’t think about them as about “real custom control”, because they are useful only for me in my very particular application. In the most common cases I don’t reuse them at all out of application scope. But from time to time I discover that some of them are good for common usage.
Sometimes I find good examples of controls from other systems or chargeable control kit. If one man make something, other one could make it also. =) By the way it’s a great challenge.
When I get know a smart tag closer, I’d decided that some of controls can be extended. It’s just like using extension methods to create DSL, helping classes and so on to write faster and easier. The same story with controls.
So there are several reasons why a custom control appears:
After creating some stuff, you’d like to use it from time to time in a different project. How to install it on VS Toolbar, add to “Add reference…” dialog and how to avoid underwater rocks – all this will be uncovered on next few pages.
When you have project with tuned custom controls and you feel fine how they works and looks like – you probably automate install actions. What you have to do to install controls:
I’m going to show you how to do almost all of this numbers programmatically in code snippets. Assume that control’s library called myCustomControl.dll. It’s up to you how to combine them for nice looking application. ;)
I’d like to continue describing how to create a smart tag. Previously I wrote what is smart tag and how to create it. In this post I’d like to tell how to create binding for the single field.
I assume that you have already created a custom user control, apply designer attribute and ready for to go ahead. As in the previous post I strongly advise to use ReSharper.
I’m going to show you how to create a similar functionality for your control’s smart tag as at Property view
Implementing this you can save a lot of time that was spent on browsing Property view in order to setup appearance and behavior.
For a long time I was wandering how easy and comfortable to work with smart tags. Actually I didn’t knew how it was called officially, but anyway I thought (and still think) that this feature is awesome! Some time ago I’ve started to develop my own components and also spend more time tuning user’s interface. I found that it’s very time consuming and boring to setup necessary properties from the Property view. Its okay to setup few controls in little program, but when you have over 30 complicated views with custom components – you quickly became in a sad mood. So I decide found out how to create for my controls those pretty little triangles on the top right corner at the most standard components.
I found articles, books; I performed several tests and finally made what I want. And you know, it’s really helps me with development! Time saving in action! )
Now I’d like to share how to make it from the very beginning.
For all described actions below I used VS2008, ReSharper5
Smart tags are menu-like user interface (UI) elements that supply commonly used design-time options. Most of the standard components and controls provided with the .NET Framework contain smart tag and designer verb enhancements.
You can find three main parts in a smart tag:
Performing changes in smart tag, you change underlying control at the same time.