output a line in a batch *without* crlf

Learning notes July 5th, 2008

Learned from here: Progressive Dots, this is a MSFTer who developing LiveMesh.

set /p CRLF=.<NUL

try this in command window, you will get a ”." output.  "set /p" is used for get a input with a specified prompt, "<NUL" make it return immediately, so "set /p CRLP=.<NUL" generate a dot without carriage return.

It’s a good trick, but as always, I hate .BAT files…

A page which crash Firefox 3.0

HTML, Javascript June 17th, 2008

Just downloaded Firefox 3.0 and found this URL will make it crash:

http://www.nikhilk.net/entry.aspx?id=198

Looks like it crashed in Javascript execution…

updated: looks like because of silverlight?

Write code with no getters???

Learning notes June 17th, 2008

One of my friends shared a blog post to me, at first it looks like quite a good practice, however after I read and think over I feel I am quite disagree with this guy. It’s a quite interesting debate, I am wondering if you guys like it or have your opinions.

In this blog (http://michaelfeathers.typepad.com/michael_feathers_blog/2008/06/the-flawed-theo.html ), someone tell a story that write code without setter will have great benefit for TDD:

“John Nolan, gave his developers a challenge: write OO code with no getters. Whenever possible, tell another object to do something rather than ask. In the process of doing this, they noticed that their code became supple and easy to change. They also noticed that the fake objects that they were writing were highly repetitive, so they came up with the idea of a mocking framework that would allow them to set expectations on objects - mock objects.”

Someone(http://peripateticaxiom.blogspot.com/2008/06/tdd-mocks-and-design.html ) extended his idea and provided a code sample:

“Suppose that we want to print a value that some object can provide. Rather than writing something like statement.append(account.getTransactions()) instead we would write something more like account.appendTransactionTo(statement) We can test this easily by passing in a mocked statement that expects to have a call like append(transaction) made. Code written this way does turn out to be more flexible, easier to maintain and also, I submit, easier to read and understand. (Partly because) This style lends itself well to the use of Intention Revealing Names.”

Those idea looks great at the first sight, but at least for me I complete can’t agree with the second guy, I feel what he *suggested* is what I will *avoid*. Maybe he just gave a bad sample, however from his blog’s long debate it looks like he is quite confident with his idea.

Reference reading:

Getter/Setter debate: http://moffdub.wordpress.com/2008/06/16/the-getter-setter-debate/

Getter Eradicator: http://martinfowler.com/bliki/GetterEradicator.html

Why getter/setter are evil: http://www.javaworld.com/javaworld/jw-09-2003/jw-0905-toolbox.html

Doing it wrong: getters & setters: http://typicalprogrammer.com/?p=23

I would like to hear your opinions….

Dump SQL Server Express’ DB Schema

Learning notes, Visual Studio June 4th, 2008

I am quite feeling lost since SQL Server 2005, SQL Server Express don’t come with the "Enterprise manager" any more… I used to do many stuff under that Enterprise manager for SQL Server 2000 before.

One simple task I need to do is dump my database schema and transfer to another server, I can easily do that before in Enterprise manager, now I don’t even know hot to dump and generate the SQL statement… fortunately I found this tool:

http://www.codeplex.com/sqlhost

Database Publishing Wizard

Download the Current Release (1.1)

Localized versions of 1.1

The Database Publishing Wizard enables the deployment of SQL Server 2005 databases (both schema and data) into a shared hosting environment on either a SQL Server 2000 or 2005 server.
The tool supports two modes of deployment:

  1. It generates a single SQL script file which can be used to recreate a database when the only connectivity to a server is through a web-based control panel with a script execution window.
  2. It connects to a web service provided by your hoster and directly creates objects on a specified hosted database

The Database Publishing Wizard provide both a graphical and a command-line interface. In addition, it can integrate directly into Visual Studio 2005 or Visual Web Developer 2005.

My suggestions on Web2py’s route design

Learning notes June 3rd, 2008

Learning web2py, it’s an excellent yet young python web framework, I just wrote a few suggestions in the dev group: (route to controllers- Some idea may take from ASP.NET MVC’s design)

I am learning web2py and very new to Python, so I could be wrong or I am not yet understand Massimo Di Pierro’s principles, just some opinions for discuss. 

Looks like the URL rules  /[applicaiton]/[controller]/[function]  is hard coded, I saw the code in main.py (lines near 140) :

            request.application=items[0]
            request.controller=items[1]
            request.function=items[2]

And also I found /static/… is hard coded as well.

Yes, with rewrite.py(route.py), we can rewrite any URL in this format and rewrite any this kind of URL to whatever we want. However there maybe some design which could be more flexible and yet keep CoC in good shape.

Look at the latest Microsoft ASP.NET MVC (now in preview 3, you can read this blog http://weblogs.asp.net/scottgu/archive/2008/05/27/asp-net-mvc-preview-3-release.aspx to get some general idea), it also have a route mapping mechanism, you can write your rule to define which part means "controller" which part means "action", if you read the blog post I give, in the end part it introduced the route.

Something interesting is, that new added route part is NOT a part of ASP.NET MVC framework, it’s actually useful for some other senarios, e.g. new release ASP.NET dynamic data applications(ASP.NET’s answer to scaffold)

My points is, a more flexible routing mechanism could make the architect looks better and more flexible and you won’t need to give up the compatibility and CoC principle.

ASP.NET MVC’s design learned a lot from Ruby On Rails, actually RoR’s route design is also quite flexible (refere to http://manuals.rubyonrails.com/read/chapter/65)

Good comparing of GAE Data Store .vs. Amazon Simple DB .vs. MS SSDS

Learning notes June 2nd, 2008

Found a good comparing paper on:

Comparing Google App Engine, Amazon SimpleDB and Microsoft SQL Server Data Services

Very good articles on MVC, MVP and more.

Learning notes, TDD May 31st, 2008

Very good articles on MVC, MVP and more.

Interactive Application Architecture Patterns

An Introduction to the Model-View-Controller, Model-View-Presenter, and Presentation-Abstraction-Control Patterns

Presenter First approach in MVP

Learning notes, TDD May 28th, 2008

A colleague of mine recommended me a great paper to read:

 "Presenter First: Organizing Complex GUI Applications for Test-Driven Development", agile, pp. 276-288, AGILE 2006 (AGILE’06), 2006.

I really like the idea in this paper, it’s practical and useful in daily development life.

There are many articles or implementations and even courses talk about MVC or MVP, but most of them only gave very simple examples for them. Yes, it’s really easy to understand or sounds clear for a simple M-V-C piece or simple M-V-P piece, however in real life, a complete application contains many Models, Views, and Controllers/Presenters, this will be much harder than a simple sample.

This paper give a great approach in MVP best practice, I am still learning more and will do some experiment  development, but I already feel I should strongly recommend this paper.

More valuable links and examples, videos here:

http://www.atomicobject.com/pages/Presenter+First

ASP.NET MVC Preview 3 just released

ASP.NET, Learning notes May 27th, 2008

Scott’s introduction: http://www.microsoft.com/downloads/details.aspx?FamilyId=92F2A8F0-9243-4697-8F9A-FCF6BC9F66AB&displaylang=en

download: http://www.microsoft.com/downloads/details.aspx?FamilyId=92F2A8F0-9243-4697-8F9A-FCF6BC9F66AB&displaylang=en

 

It looks much neater than the previous version. Looking forward the official launch.

Dialog based Winodws CE MFC

Windows Mobile / CE May 27th, 2008

Problem

Meet 2 weird issue in a simple MFC Dialog based Windows CE application:

1. MFC’s single instance mechanism seemed don’t work (My dialog based app won’t quit, it just hide and wait for activated when user try to run it again) , a new instance always come up.

2. Click "today/start" menu item, the today screen don’t show up, instead it show my dialog app’s UI.

3. Smart menu remain to be my dialog app’s smart menu when today’s screen is displayed.

Solution

Read the MFC code, it does have single instance check by create a mutex, however it seemed that if I hide the app’s main window by ShowWindow(SW_HIDE),  EnumWindow() will not able to find the previous window handle, so MFC think there is no previous window to activate and it run a new instance.  I change to ShowWindow(SW_MINIMIZE), the problem 1 was fixed.

For problem 2, 3, eventually I found the solution from here:  http://www.pocketpcdn.com/articles/today_friendly_dialogs.html 

Question

I have created a dialog based application. It works ok. But when I click Today item in Start menu my program is shown instead of Today screen. How can I fix it?

Answer

This is because Today application is like a desktop on PC. When a dialog has no parent a Today window is considered as a parent window. This behaviour is necessary to get access to popup messages. For example when message about low battery is shown and you switch to another application. The onl way to access this popup message window is to call Today program. But such behaviour is not necessary for windows that could be accessible from menu.

To fix it you should change dialog’s WS_POPUP style to WS_OVERLAPPED.