Stefan Says

Opinions on ASP.NET, ASP, databases etc
posts - 38, comments - 24, trackbacks - 0

Wednesday, July 07, 2010

EF4 or NHibernate - I've made my choice

Ok. So I've really given it a fair try. I've been to different sessions and courses on EF4 really wanting to give it a chance. However, now when I really had to put it to use in a project I just hit the wall...

I dont know, while Entity Framework 4 sure has it positive sides -  such as great linq support, nice designer - there a lot of things missing. I encountered such as case where I needed a pretty simple query (note - query, not a view, not a SP)  to build up my entity.  I soon realized I had to turn into manually editing the EDMX file for that. It should be possible, but considering you need to do changes to the SSDL, the CSDL AND the mapping part of the file - all referencing each others types - with long namespaces etc - and I wanted to create a one to many relationshoip as well, I simply couldn't get it working.

Look here for the "manual" http://msdn.microsoft.com/en-us/library/cc982038.aspx

And in NHibernate I did it like:

  <class name="ShippingDevliery"  >
    <id name="ShipDate" column="ShipDate" >
      <generator class="assigned" />
    </id>
    <property name="OrdersCount" />
    <set name="Orders" cascade="all" lazy="true">
      <key column="ShipDate" />
      <one-to-many  class="Order" />
    </set>
  </class>

  <sql-query name="loadShippingDevliery">
    <return alias="p" class="ShippingDevliery" />
    <![CDATA[
      select shipdate, count(*) as OrdersCount from Purchasing.PurchaseOrderHeader where shipdate>:shipdate group by shipdate order by shipdate
    ]]>
  </sql-query>
IMO, all in all MS made it way to complicated. You define the model, the conceptual classes (your domain classes) and the mappings in different sections interlinking witth each other where in NHibernate basically you just concentrate in the mappings.

Which is the most important part here to talk about! To be fair, what matters most is the conceptual model. The persistance framework MUST be flexible enough to bend itself to support that. EF4 is so much database first - and for smaller projects where you end up using simple one to one mapping against your domain entities and your database tables.

Maybe, maybe, maybe Code First will change that, but come on, its only a CTP right now.

Seriously, an ORM is supposed to make things easier...And it need to extensible to help us (developers) overcome the shortcomings.

I also hear a lot of fuzz about change tracking. Self tracking entities. While it sounds good, its also the kind of thing you should watch really out for. I mean sending whole entities over the wire back and forth instead of mapping to screen based DTOs so much puts your application into a "CRUD" type of.application. Which also might be fine for some, but putting the extra burden in your client (or mid tier) to make it command based I think will be benefitial in the long run.

oOrder.Save()

compared to

oOrder.ModifyShippingDate(...)
oOrder.InsertNewRow(row)
oOrder.Deleterow2)
etc.

Basically the latter will give you a lot of extra value, you can sane the users *intent*, we didn't just save, we saved because someone modified the order etc.

I might take a look at EF4 later when Code First is released and the battle isn't over I guess, but for now I put is aside and kleep on focusing on NHibernate.

posted @ Wednesday, July 07, 2010 2:58 PM | Feedback (0)

Wednesday, June 23, 2010

Some EF4 progress

Ok, some progress on my EF4 adventure. I have added a new (at least somewhat) better VS2010 solution for download at my main site, EF4 Iteration 2 . It 's a simple master/detail (order/orderrow) example from AdventureWorks.

While at NDC2010 I attended the EF4 sessions by Julie Lerman and had quite a few aha moments, especially regarding the codefirst possibilities which will be available later. I asked about my "dependency problem" I've talked about earlier - how the objectcontext instantiates the business POCO classes - and Julie was kind enough to hook me up with Patrik Lowendahl who simply explained to me "it's just a matter of moving the objectcontext out ot the model" To be honest at the time I hadn't even understood the simple fact that objectcontext is NOT part of the model... So the new code in iteration 2 is not perfect but a step on the road, I've moved the objectcontext up to an assembly just below the GUI and also added repositories around it, so to speak.. I would in a real life scenario use interfaces and a IoC, l.ike MEF to load the assemblies but in this example I simply reference them.

All in all, I've spent a lot more time on this matter than I thought upfront. To be fair the actual EF4 obstacles I've encountered has been fairly easy to get around, but me deciding to go the POCO route has given me a lot of trouble. As I said, I have seldom/never?? been in a project where that really matters (pluggable dals could be solved in other ways), but I do see the beauty of it.  And to be honest it's just a matter of getting a single proof of concept app up and runningg and then the "lazy engineer" inside me will start finding ways to generate code/do shortcuts wherever possible.

However, one of my main objections about EF4 is it just supports SQL Server...I mean I could instead choose to use nhibernate, or even better fluent nhibernate and instantly be able to swap database engine...In my consulting business SQL Server is fine, but I do have a lot of existing websites running against MySQL.. So honestly, I am not completely sure yet...

posted @ Wednesday, June 23, 2010 9:53 AM | Feedback (0)

Thursday, June 10, 2010

Summer of 2010

Ok. Long time no seeing...

Back in web business now after a few years filled with consulting gigs. I am self employed and for the last 10 years I've been fortunate to run projects completely on my own. Kind of where the customer has handed over business problems to me saying "Solve it with applications like this and that" - "we don't care HOW, just do it and deliver".

This has put me in a position where I get to do everything, design database/datamodelling/coding/deployment etc. It sure has broaden my skills, strengthen my self confidence to see things working as it should, but when noone ever reviews your code and solutions there is a risk you eventually become lazy. You do things the way you usually do. You stop taking input from community, listen to experts, cause you do know what you need to deliver what your customers are asking for.

And they are asking for applications and solutions, not technology. They don't give a shit if you are using LINQ or not. And that of course makes sense. Problem is for me, I feel my coding style is soo outdated nowadays. I mean I do multitiered applications, I do webservices, I do ASP.NET solutions delivering exact what the customers are asking for, but when I  look around or listens up for a while,  people aren't exactly buzzing my choice of techonogy. Which in short means
- asp.net webforms
- ui -> business layer (using SubSonic 2.2) -> DAL (SQL Server 2008 or MySQL)
- client side reporting using Component One
etc

While I have adopted generics, I generally stay away from LINQ cause I feel its weird. Why put the effort into trying when I can custom code the same in just a few minutes using my old, plain code, coding style.

So now is the end of all this. I will dedicate this summer (well apart from bathing, grilling and playing with the kids) to upgrade myself, my old coding style.

First I  started using EF4 (Entity Framework) just two days ago.  It was hard, but fun, to try to get my first multitiered up and running. Thanks god for Google and people who have taken this road before me. Result so far is in my article on Entity Framework 4

I have a long way to go still with EF4, not only in terms of understanding it, but also to try to upgrade all my existing (Subsonic) projects to use it this way.

Next I will jump on SQL Server Reporting Services, Sharepoint and WCF.

While real life coding and thinking is a must, I will take a shortcut and attend the NDC2010 in Oslo. Hopefully it will help me a bit on the way, also give me some inspiration !

Anyway, expect to see some "journal" like articles on aspcode.net soon, it might not be completely correct code I present, but be assure my point of view is to try to see HOW you apply the new technology in REAL WORLD applications, the actual technology presentations are already spread all over the web and there's no need for me to write about such things.

posted @ Thursday, June 10, 2010 10:13 PM | Feedback (0)

Tuesday, September 23, 2008

5 reasons I wanna use C++ instead of C# and vice versa...

In a recent project I just needed to do some C++ coding again. Havn't done anything serious with it in at least 7 years...
Those who know me a little more know I started out with Microsoft C (OS/2 1.3) in 1992 (using the fantastic - yes I mean
it, I am not being sarcastic - textmode editor, MEP - simply m.exe). Then I got into VC1.52 and were later for some time really deep down into Windows NT system programming. All in C or C++. I then embraced ATL/WTL to benefit from not having dependencies to MFC runtime or anything. When .NET came along I was a bit slow to get on the train, but these days I don't do anything (except when I for some reason really have to) outside of C#.   

Anyway, as I said, needed to do some C++ coding and downloaded VC++ 2008 Express.  It did take a few days to get on the track again. I mean just to remember the syntax for declarations and things -  private: protected:, class ends with ; etc.
But I got the project up and running and one thing that struck me was the performance. Not only for the resulting exe file
(pure execution performance and memory usage etc). But also the IDE itself, when for example debugging - it's just so much more lightweight. Anyway I'll talk about more about that in

5 REASONS TO SKIP C# IN FAVOR FOR C++   

1. PREPROCESSOR
This is something I really missed in C# when I left C++. When Generics was added it sure saves you a lot of typing , but
still it's not up to par...


2. LIGHTWEIGHT
Ok I said debugging pure C++ code etc is more lightweight. Not sure why but that's my experience. However, more important when talking overhead, the C++ generated EXE will be more lightweight. A C++ exe file will most certainly use less memory. It will also start up faster. I've heard/read some posts andf articles stating that "there will be a slight delay/overhead" when firing up a .NET exe file bla bla. Well, my experience says it's not that small. And there could be large consequences. Say you have an app being called 10 times a second - I talk more about that in the conslusions. Also, memory usage. Have you ever wondered about why your PC of today (which, technically speaking is countless times faster than the one you used 8 years ago) still feels pretty much like it did back then. All apps consumes more and more memory.

I remember when I put pride in delivering the smallest possible exe file, linking to a mimimal crt library cause the standard one was soo "bulky", at least 20KB could be stripped or whatever the numbers were...    I have some more meaningless numbers: I took a small console app I had in C# and started it up and looked up used memory in task manager. 27000KB. Rewrote it in C++. Exact the same inpout/output. It took 7000KB. 


3. PERFORMANCE
Ok. This is controversial. If I say something general like "C++ in faster than C#", I know people will say things like "it's not true, C# compiles to machine code as well". And I know all that. My point is that the framework classes does contain a lot of  (sometimes unnecessery) code, for error checking etc...There's also code and time delay involved when talking garbage collecting etc. Not saying  that's bad (in most cases it's good, I mean I do have it on #4 for reasons to use C# instead of C++). But from a pure performance perspective the freedom of pointers and things like pointer aritmetics etc in C++ is a big plus. However of course, also to consider is that in the "real" world, slow actual code execution is seldom a problem - whenever I need to do some optimization for my own/other peoples code, database access/correct indexing etc is always where I start. Nontheless there *are* areas where code execution speed really matters.

4. THERE ARE LOTS OF GREAT LIBRARIES AVAILABLE
Say you want to do some image handling. From C++ you'll have full and quickest access to ImageMagick dlls. I was also pleased to see (since I am now a complete MySQL geek) : mysqlpp.
Code like:

 

 CFoo *pRes;
 try
 {      
  mysqlpp::Connection conn("db", "localhost", "root", "whatever");
  mysqlpp::Query query(&conn);
  query << "select * from foo where bar='" << szUrl << "'";
   if (mysqlpp::UseQueryResult res = query.use())
   {
   if ( mysqlpp::Row row = res.fetch_row())
   {
    pRes = new CFoo(row);
   }

   }


  return pRes;
 }
 catch (const mysqlpp::BadQuery& er)
 {
  // Handle any query errors
  std::cerr << "Query error: " << er.what() << std::endl;
 }

And where CFoo is defined as (thanks to preprocessor)

sql_create_3(CFoo,
    1, 0,
    mysqlpp::sql_int_unsigned, id,
    mysqlpp::sql_datetime, createdate,
    mysqlpp::sql_varchar, bar
 );

I can live with code like that!

Also there is boost libraries as well of course.  Only problem with those is they are developed by guys a million times smarter than me. It does take some time to figure it out how to use it. For example I was struggling for hours with understanding the program options library, but when I did get it to work I found out that, hey, I can use config files and have them overridden by command line if I want to.   


5. NATIVE WIN32 APIs
Must be a plus for some, a minus for other. For me its a plus since I have my roots in the world of Win32 system programming. I still have trouble with the semaphore/mutexes etc in .NET but as I said, that's just because I nowadays use them rarely and I am no used to the raw APIs.

 

And 5 reasons I wanna use C# instead of C++...

1. ONE UNIFIED ENVIRONMENT
Whether it's a website (asp.net), console app, Windows GUI app for even a Windows Service. All done with the same programming language in the same IDE. That's the main reason I have been able to stay in the C# line for seven years or so without complaining.


2. LINQ
Still just starting out, but the elegance of LINQ code is just remarkable. Now, I would point out that I would never go as far as using LINQ to SQL (the day I leave control over how SQL is constructed and exactly when a statement is executed will
*never* happen. My own handcoded sql generator is good enough, at least for me and my modest projects). But LINQ to objects - any day of the week, and LINQ to DataSet - sure!

3. DLL, LINKING, INCLUDEFILES.
no dll hell. I mean in the C++ world: include header files/linking/. Setting paths here and there in the settings. Dont link your debug version with a third party release version etc...Also things like forward declarations etc : I think I'd go so far and say that C# as a programming language is superiour than C++. Also the whole development process as a whole is a lot more easier.

4. POINTERS, MEMORY, GARBAGE COLLECTING
Speed comes with a cost. In 99 percent of the time I choose convinience over speed. I remember in the middle of 1990, when pointer faults (especially when debugging in VC 1.52) caused the whole Win3.11 box to reboot. I'd say 80 percent of my time in this first C++ project in seven or so years was spent dealing with pointers due to me being so rusty with them. And reading up on the third party dlls I used - i.e who allocates memory, who frees it.

5. DEVELOPMENT TIME
Harddisk space is cheap. Memory is relatively cheap. Development time is what costs. Of course I understand that's the main reason frameworks and apps can keep getting bulkier and bulkier. As I say, I use the .NET framework for *everything* to the point I couldn't even remember the parameters to fopen/frwite etc. C# is in my eyes the programming best language ever,  .NET framework IS convinient and with the additions like LINQ etc it's FANTASTIC.


CONCLUSION
So, whats the point with this post? Well, basically none I guess :). No seriously I am saying that I had forgot the positive sides of C++. And I now found that there is indeed room for it as well. I might look into the Managed C++ soon, cause if I am not wrong I think it's possible to lazy load the .NET dlls. Cause while I have found that there are a lot of free C++ classes floating around, I still have some C# code I simply can't find an equivalent of. Not to talk about all my existing "business objects" codebase.

Another idea of C++/C# marriage, which I even already have implemented in another smaller project, is to have a C++ exe signal (through a file or whatever) to a C# program. Here I was faced with a third pary app which had to interface with my own (.NET) code. The only way it could do it was by calling an external exefile. It could be called maybe 10 times a second, so I really didn't want the .NET framework process overhead. Solution was to create a C# exe constantly running (could/should be a service of course) waiting for a file in a certain directory. Always running is the key here.
I then created a small C++ exefile which was the one being called from the third party app. Lean/small app, low overhead, all it does is signal to the C# app through the file. So the C# app does all the work using my existing classes and code, and returns back through another file. And my C++ exe then exits - returns to the external app.

 

 

 

 

 

posted @ Tuesday, September 23, 2008 11:03 AM | Feedback (0)

Tuesday, May 20, 2008

Ok, an aplogy to Microsoft

Ok, maybe you read my earlier post about me not wanting to upgrade to VS 2008.

Ok, I admit it. I was wrong. I bow and apologize to Microsoft. But honestly, I didn't know about the SP 1
which finally makes the express versions useful in real life. The reasons Express versions earlier have been completely rubbish for other things than as a toy is not being able to precompile (dll in bin folder - so called Web application projects) and not being able to add additional (for example class projects) into the solution.

Ok, you say, why don't you use Visual Studio Pro or better, you cheap m*f*er? Well, I have. I have bought all Pro (or eqiuvalent, sometimes I have had the MSDN enterprise subscriptions) versions since VS 97 and  I am sick of installing bigger and bigger files and downloads, taking longer and longer to work with. I want something else. The sound of "Express" - as in quick, lightweight , with no rubbish/extra tools/sourcecode management integration (I do it outside) /modelling tools etc - is the sound of music to me.

Now after a few days of testing, what can I say about the options I have explored - remember I don't want to upgrade to VS 2008 Studio Pro:

a) SharpDevelop. Amazing. My WinForm/console solutions loads in notime and I really like the IDE. My existing ASP.NET apps (created in VS 2005) are OK to work with. Since I seldom use the visual GUI designer window anyway. But honestly I really miss the automatic code generation (i.e hooking up events etc) from it. So I haven't still completely decided that's the way to go.

b) RAD Studio, Borland. Downloaded an eval of it. As I suspected this is a giant beast just like Visual Studio Pro or higher and just removed it asap. Not even sure you can  do asp.net apps with C#, at least it seems to default to delphi.

c) 2008 Express Editions of Visual Studio.
This is where I am now. Just installed trhe SP1 beta and I was so thrilled when I loaded up a solution for a smaller site I have, just one asp.net website, one dll project and a supporting console batch app. But everything has compiled well and I have debugged it with breakpoints and all seems to be working ok!!! This might be it, perhaps!

Next: Need to explore the WinForms solutions I have. Not sure I need to download the C# Express separately or not, but I'll keep you posted.

Btw: no child yet...Still waiting. One week over expected date today, but my first girl was 23 days(!!!) late and my second 14 days. So, I might still have another week to explore IDE:s... 

 

kick it on DotNetKicks.com

posted @ Tuesday, May 20, 2008 1:15 PM | Feedback (0)

Monday, May 19, 2008

The road I am taking and where is Microsoft going?

Let me start by saying it's been a long time since I updated the blog. I have been busy with work as well as my private life. Since we are expecting our third child *any* day now (actually expected 6 days ago),  I have been working a lot on the house these last months to get ready for another baby again.


Anyway: considering my last talk about MySQL vs MSSQL and the fact that I decided to choose MySQL sure deserves a followup. I will tell you how it's working out for me.

I will also talk some about where I'm heading with regards to development, cause while .NET will continue to be my platform I am not sure MS and Visual Studio will be.

Anyway lets start with an update on databases and database management tools. MySQL is simply looking better and better to me each single day. Performance is pretty amazing. Had some full text indexing issues which basically comes from the fact that MySQL only uses one single index per query when it comes to optimization. In short I wanted to do a where matches(...) and anothercol=somevalue. Actually it was even worse, it was a join with another table and it basically had my 2 million record first table being table scanned even though I did have an index on anothercol.  But it was easily solved by adding the information joined in into the full text index . Makes update and inserts a somewhat slower but in the end that doesn't matter.

As for the administration tools: Of highest importance for me is,an admin tool needs to start up ASAP. And I mean *A*S*A*P*.  To be honest, I feel happy every day I *DONT* need to fire up SQL Server Management Studio. Since I have some clients running SQL 2000 I do need to run SQL 2000 Enterprise Manager and I feel ok with that. It loads up quickly and feels "light" and responsive. And Management Studio simply doesn't. 

Cause lets face it. I am a developer. I understand MS is going for the slick look when it comes to OS (Vista glass gui etc) but when it comes to development and management, my opinion is MS should focus to improve performance and load time for each version. Not adding slick GUI features and stuff making it slower and slower.

With SQLYog on the other hand, I mean, I can't even blink before the GUI is up.  

Now lets turn to IDE. I have been a fan and practically lived in Visual Studio since VS 97. Yes, I am that old. Actually I'm even older - even did som Visual C++ 1.52 development (maybe there are some other dinosaurs out there who knows what I'm talking about, otherwise lets just say, it was an integrated IDE for compiling 16 bit Windows apps, MFC and C++...). Must have been 1995 or so. But VS 97  was a match in heaven. I still keep all the keyboard bindings from VS 97 in my Visual Studio of today. Which by the way is VS 2005.  VS 2008??? Lets start talking about that. I honestly don't know what to do. If you had asked me 10 years ago I would probably have drewled cause "a new version, technically much better is available". But nowadays, I really feel like, will it really make my apps that better??  Cause in the end that's what matters. And the reality is - I do have VS 2003 solutions I still need to maintain. I simply can't have yet another version of VS on my box.

So what to do? Exploring other options of course. Searched for Borland C# Builder - seems to be gone, now integrated into a RAD Studio or something, gives me the feeling of another beast. So - downloaded SharpDevelop. Just a 8MB install file. I can live with that :) Took a minute to install. Opened up a Windows Forms solution I have (pretty small and simple). Compiled. Run. Set a breakpoint. Everything is WORKING!!! Simply fantastic. So lightweight, still all I need! Next - one of my ASP.NET sites. Loaded the solution. Ok, no ASP.NET visual designer. I really can live with that. Next, run. Nothing happened. "Cant start dll project" or something. Make sense, but how to fix it? Googled some and found that we need set the "Start external program" to C:\windows\Microsoft.NET\Framework\v2.0.50727\WebDev.WebServer.EXE.
I hooked up the command line arguments /Path:C:\working\systementor\sites\airengines\airengines  /port:8001 /vpath:/

And hey, it's running. Set up a breakpoint. Browsed to the page. Hey - back in debugger!!! All is working. I am amazed.
So, I will give this a serious try. I honestly mean it. Of course, so far I have opened up two simple solutions, I have one solution consisting of around 15 different projects being console apps, class dlls , Win Forms apps. If that one works I know I am home. I will report more on this, I promise.

So, tip to MS: the view of the world for us developers might not be yours. What's important is

- quick and lightweight tools and IDEs. Quick to fire up and responsive.

- small installs. It's not reasonable to spend hours and hours to install the IDE - and then database engine. Not to forget hour(s) to download first. 

 -Flexibility - in the dreamworld I could take any computer at all, and have it fixed and ready for compilation and work in just 15 minutes.
  
Cause I am moving to a Internetnet oriented architechture for all my stuff. I already keep all my sourcecode on a remote box (with SourceGear - yes it's free for a single user). I need/want to get rid of the dependence on my specific development box for compilation and code writing - and to be able to do that I simply need to be able to set up a new box in minutes, not hours.

So I will try to keep you all updated on this matter, however, kind of depends on the baby when you'll here from me next :)

 

  kick it on DotNetKicks.com

posted @ Monday, May 19, 2008 8:46 AM | Feedback (0)

Sunday, January 06, 2008

10 reasons why I chose MySQL over MSSQL2005 Express

as the preferred database engine for my web sites.
(price not being one of the reasons)

I currently have around 100 public websites spread over five servers. For ease of management I have started to look them over and standardize their technology.
I had to decide which database engine to use. These are my OWN highly personal opinions and arguments which made me take the decision based on the needs I have. I am not trying to start a database war here :)
But as the title suggests, I have chosen to use MySQL. Here are the 10 top reasons why:

- LIMIT. In a typical webapplication paging is needed and the LIMIT clause is a simple way of just retrieving the needed records from the database. The traffic between
the database and web application is kept at minimum, as well as the memory required for the web app.

-  SQL_CALC_FOUND_ROWS. That select modifier works in conjunction with LIMIT and lets you retrieve the total number of rows you would get if we weren't LIMITing. I have a full C# code example
on this at ASP.NET, MySQL and efficiant paging

- memory requirements etc. Let me just say this: MySQL is so lightweight compared to MSSQL. It might not scale as well, it might not handle the same amount of transactions as fast as MSSQL,
but I don't have those requirements. With a download of 22 MB compared to 50 (or even 250 if you want fulltext) MySQL wins this round in my eyes.

- read performance. I agree: when it comes to transaction intense applications I still recommend MSSQL. but for web apps I have chosen MySQL. A web app is typically mostly reading data, not many
updates. In MySQL you can use the MyISAM storage engine, which uses an extremly fast table locking mechanism, allowing for multiple reader/single writer.  

- management. Never thought I'd say this: I have learned to master and really like SQL Enterprise manager, I am also beginning to like SQL Server Management Studio, but, for a remote webserver
nothing beats phpMyAdmin against MySQL. On my development box I run SqlYog.

- backup/restore/moving data. MySqldump is a fantastic tool for moving data from one server to another. Spits out CRERATE TABLE/INSERT statements into a textfile.
So genious, Microsoft recently developed their own version, Database Publishing Wizard.

- MySQL is a full version. Since I said I woudn't talk about price I need to compare MySQL against MSSQL 2005 Express. And that version is crippled. Uses max one CPU,
uses max 1 gigabyte (GB) of RAM, 4 GB maximum database size.

- it's widespread. I have done quite a lot work lately against Wordpress. Having my own stuff in the same database as the Wordpress data opens up a lot of possibilities

- fulltext engine. For MySQL it's inside the 22 MB. Nothing to download/install/configure.

- multi OS support. I now have a Linux box in my machine park as well, since Wordpress is needed. So, being able to run MySQL on Linux as well as Windows sure
is a plus for me.

Last - consider I had all my experience in MSSQL (been using and coding against it daily for 10 years = since SQL 6.5), but still decided to go the MySQL road.

Messages for Microsoft:
- make it easy to upgrade an existing SQL 2005 Express installation to include full text engine as well. A 250 MB download is a joke.
- LIMIT and SQL_CALC_FOUND_ROWS. Something like that. Database support for paging is crucial for web apps, tricking it with TOP (and two separate sort /asc/desc) is not comparable. I know it's not SQL standard, but
I don't care. I need the best functionalty for my solutions, not the "most standard".

These are the two most important reasons I "left you" with regards to my web sites.

Messages for MySQL AB:
- do something about your own admin tools. The Query browser for example is horrible to work with. Luckily there are a lot of third party tools.
 

kick it on DotNetKicks.com

posted @ Sunday, January 06, 2008 7:41 PM | Feedback (0)

Tuesday, January 01, 2008

Switching to MySQL in 2008

My directions for 2008

I will do some major changes when it comes to technology in 2008. Being an independent consultant (contractor) is not
all about being totally independent, of course. As in any business you need to adapt and be able to offer what your clients need. Not what you might consider the best/optimal (you can of course always come with  suggestions), but in the end the client makes the decision about which platform and solution to choose, and things like existing  ardware/software/knowledge often plays an important role in it. Therefore I have been doing a lot of ASP.NET, C# against MSSQL Server. However, if it was just up to me, and not taking any old luggage into consideration, I'd actually switch the MS SQL backend to MySQL!

Which is the direction I will try to take for this year. Lately I've been doing a image gallery system for a client, and since I had the freedom to choose the architechture I went for ASP.NET, C# and MySQL. Even though I live and bread MS SQL server and sps I can't say I made the wrong choice. Yes, some initial problems, no doubt,  but, I must say there are certain things making MySQL the optimal database engine for a web solution.

+ price of course. Nothing more to say. The SQL 2005 Express limitations needs to be removed ASAP in my opinion, cause to me it's very much a developers database...


+ built in full text index. I have never needed full text index until a project I entered a few months ago. I looked at getting it up and running on my SQL 2005 Express development box. However, an extra download of 250 MB was needed. I also *think*


+ paging. My favorite! This is SOOO typical a web application. Implementing paging in MSSQL is not fun at all. Getting acceptable performance out of it is possible, but coding hard to generlize and reuse.  In MySQL it's a matter of adding LIMIT X,Y to the end of the select statement. And not to talk about SQL_CALC_FOUND_ROWS. Cause typically you need to get the page of rows  but also the total number of rows, as if we were not using the limiting. Typically you do
two queries, one select count(*)... and one select * limit x,y. But with SQL_CALC_FOUND_ROWS you get that anyway.
Yes, might not be SQL standard, but I don't care. I don't get paid by creating the most standardized solution, I get paid by delivering a solution with good performance and preberable a low footprint. I have published an article on this, ASP.NET, MySQL and efficient paging.
   

On the minus side:
- Microsoft default medium trust configuration. Medium trust is a good thing, it's not about that, I just feel that a lot of webhosts has no idea about what it's about. They take the default configuration (recommended by Microsoft) and uses that. And the default medium trust configuration only allows for MSSQL database access...I've had numerous of conversations with webhosts about it and many, I say many, still doesn't understand  what it's about. Sure they advertise on their website of supporting asp.net, mssql, mysql etc, but still when firing up your ASP.NET 2.0 app you get the
ecurity exception cause they are not allowing MySQL from medium trust...A lot of respectable webhosts has indeed made the changes needed, GoDaddy is one of them. Hat off for them!

AdMentor PRO will always have a SQL Server driver and I will still do a LOT of SQL server gigs, since I have a lot of clients using it, but for myself and my own servers I will make the transition.

   


 
- I might be wrong here - SQL2005 installs some extra services and stuff. In MySQL it was just a matter of specifying it in the create table statement and start querying...You do need a decent stemmer though, making words in normal form.

posted @ Tuesday, January 01, 2008 9:48 PM | Feedback (0)

Friday, September 21, 2007

Dealing with large datasets in browser

It's always hard working with large datasets, I have written quite a few desktop apps of that kind - and this week I have been trying to educate myself using large datavolumes in a web scenario.

I have no trouble optimizing the actual dataaccess ( I more or less live and breed indexes and sp:s ),  but the trouble is how to design the actual interface. I mean you can't just throw in 100 000 <tr> records and then expect the user to stay waiting for it to first come up at all, and then (try to) navigate it.

The virtual listview is cool for Windows Forms and desktop apps, but to be honest I have a hard time with the existing
asp.net grid controls available - while the controls themseleves might be great - we have the problem of trying to be accessible. Meaning people without Javascript (and not to say search engines) should be able to get all our pages, so some sort of cool Ajax solution is (in my eyes) out of the question.

So - what can you do? I have been experimenting a little lately and have a few tips:

1. Use CSS as much as you can. Minimize the HTML markup.
Not
<li style="color:black;....">Hello</li>

but just
<li>Hello</li>

If you have, say some hundred or more records it CAN make a difference.

2. Are there "natural" ways of reducing (filtering) the dataset?
I have one example:
http://www.usradiostations.info/

a site listing US radio stations.

Here the first choice is state - then you select the city - and not until now you get a list of the actual stations.

If I was to do such an application for myself - for it to be really useful, I would probably have one dropdown list for states - and when selecting a state all cities pops up in a linked dropdown - which in turn lists all radio stations in a third. Or something like that. But I think there is more to it than just creating the easiest to use application. As I said accessibility
of that site has a value too.


You can even reduce it further - another example is this site on aircraft models http://www.aircraftdata.net. To reduce the dataset I took the liberty to split it into different subdomains - that being step 1. Then you get listings for that subset.

I will do some more investigations in this matter - cause it is very interesting and the task of creating an accessible, yet easily navigatable - yet again USEFUL - site might not be as simple as it sounds when dealing with larger data volumes.

 


 

posted @ Friday, September 21, 2007 3:42 PM | Feedback (0)

Wednesday, September 12, 2007

Source and version control

When setting up new box I had some vague ideas of trying the opensource road. The very example this post is about is source control. I have earlied talked about  Sourcegear but I see alot of buzz around Subversion so hey, why not give it a shot.

While Sourcegear Vault is a fantastic product, what scared me from using it (it's free for single user - which is what I needed for my websites sourcecode - so price was not the reason) is the rather hefty system requirements for the server end. 2 GB RAM is recommended. Since it's implemented as a webservice it's also integrated with IIS - and I have an idea of NOT running iis at all on my development box (but rather in a virtual VMWare box), considering I run´the built in web server when debugging my VS2005 projects.

So - off I went. First searching for info on *WHAT* and *HOW* to install Subversion. Then trying to do it. I finally got it running as a service as I wanted. And it is indeed slick - really fast and low on resources as far as I can tell. However there were some things I didn't like about it:

1. can't check out a single file. You work on directories. That's a problem with the server end - I read somewhere they are gonna implement it  in the future, but I need it now

2. can't say I found a GUI I likes. Tried out TurtoiseSVN as well as RapidSVN.  While RapidSVN is pretty close to VSS interface (which I fell like I was breastfed with, more or less) - still not close enough.

So - back to reality and Sourcegear Vault. What I didn't want was to clutter my development box with the server part - so I took a shortcut and installed it on one of my public webservers. I also get the benefit of having the code at a second location.  

posted @ Wednesday, September 12, 2007 10:18 AM | Feedback (0)