First fail with WL

As i mentioned in my plan: Building a desktop application, quite simple for the first version. I also mentioned about technologies usage: NHibernate + WPF with MVVM model.

I also did some researches on that model, also have done some projects with NHibernate ( web application).  Therefore, i am quite confident to start up. And i did start up. Put all framework code and prototype of MVVM in place, in fact i copied and pasted from others. You can find them in my should read page.

Well, things were not that easy. I ran the project, it was fine for the first look. However, it did not do any db action. In fact, i did not know why NHibernate did not contact with DB when i made some query. Even wrap them up in a transaction. I have been working on finding out why. BUT the most important thing i found out is that: I DO NOT UNDERSTAND THEM CLEARLY.

So what they actually are???

  1. I did not define my application clearly. I mean the workflow of each action. For instance, what happen when i create a new word. Since it will help me define the scope of unit of work
  2. I did not understand the article from Ayende clearly. Not read it carefully enough.
  3. Wow reading MVVM one time does not mean i understand it completely. I know it but NOT GOT it.
  4. Even though, in MVVM, the view is separated from others. However, designing a good looking view will inspires you a lot. And i am terrible at making GUI

And, what i am going to do now are:

  1. Design the GUI. It is as a part of learning XAML.
  2. Re-read 2 articles from should read.
  3. Start defining the lifetime of session. Define workflow for each scenario.

After all these fails, am i sad? NO. I am happy to find them out.

Deletion consideration

I have been working with ASP.NET for nearly 3,5 years in my company. However, i have not been using so much ASP.NET controls and other stuffs from that. My company, Catglobe Vietnam, has been built such a wonderful framework. Basically speaking, we do not need to care so much about controls and some pure ASP.NET stuffs, since we have had process for doing this. We focus much more on business logic.

Then one day, i decided to build a simple ASP.NET application, which purely uses ASP.NET stuffs. Things came a little bit for a first while. Eventually everything has been going well so far. I am going to post something about them later.

Now then, i came to a decision about deletion of an object. Let’s say a Category object, which contains Products, SubCategories.

So the category page as below:

category

So, what would happen when the button “Xóa” is clicked on each product?

Basically i had 2 options here:

  1. Process the deletion inside this page, which confirm the user and then post back to server
  2. Redirect it to another page which will take care of delete action.

( we can forget about how to delete an object since it is not the point here)

#1: We have limit information for user to see before he actually makes the decision.

#2: With the deletion page, we can show as many information as we want, with some more text confirm and warning them about the action. Furthermore, later point of time, when we decide to change the logic, information of deletion, we can easily archive it.

So, i came up with this page:

deletionpage

See, you have a certain amount of information you want to show to user.

Delete is quite serious action we always have to pay attention on.

have fun with SQL and Excel

I have been programming for more than 3 years, of course exclude the university time. Most of the time, i work with web development based on C#, ASP.NET with SQL Server. However, honestly speaking, i am not good at SQL. I just work with basic functionalities which are required to make CRUD operations.

One day, my boss gave me a task which required me to look at closely at SQL database and excel. And they were not my fields at that time, especially excel 🙁

After a couple of weeks working with requirements, i am not talking detail about the logic of task here, with the help of my boss, i have had those new things for myself, not really new for you 🙂

In summary, my task was: extract data from SQL database and format into excel file and then finally import that excel file into a new system. And the original data was not well organized and correct.

To do the extracting, i made a small window app. But the difficult thing was checking the data. Here are my steps:

  1. We have many ways to import data into SQL server. Here i work with Excel. So i import data from excel into SQL.
  2. After importing data in excel, you can customize it and make some query to get the data back
  3. Then do copy and paste the data into excel again.
  4. Make graph or any calculations to check the data again what you had so far.

The point here is that, after doing this task, i like to work with SQL and Excel more than ever. They are really nice tools.

wcf – endpoint basic

I have just finished reading about WCF – Service Endpoint basics. So what is it?

Endpoint is where consumer contacts with service. To remember about endpoint, just need to remember this: ABC of endpoint, stand for: Address, Binding, and Contract.

  1. Address: The URL of the service location: http://localhost/SomeService/Service/
  2. Binding: Define how to access the service, how to communicate with service.
  3. Contract: Define what service does

There are 2 ways of creating endpoint: by configuration and by code. Should use configuration as best practice. Since you can change it later point of time when the service is deployed without recompile the code.

Creating endpoint using configuration is quite simple. Just create a wcf library project then VS takes care of all stuffs for you 🙂

For services exposed to multiple clients, you can specify more than one endpoints so client can use the one most suitable for them. You add one more endpoint tag in configuration and make sure that the address is unique for each. If the address is the same, then the contract should be different.

Take advantage of baseAddress tag to specify the common part of the address. And again, VS already takes care of that 🙂

The default configuration generated by VS exposes meta data to the client. To turn it off set the httpGetEnabled to false.

I just wrote them down here as a way of learning it, if you do not understand or have any question, please post a comment.