Monday, March 12, 2012

Performance de Squirrel

La segunda parte de Squirrel.
En este post veremos el performance de Squirrel vs Linq to SQL y Entity Framework 4.

http://www.impulsotechnologies.com/Blog/El_Performance_de_Squirrel


Tuesday, August 23, 2011

Why so many fail when trying to move to the cloud?


First of all, I am talking from anecdotal experience working mostly with the Mexican IT scene, but it’s not restricted to it, I have observed the same behavior on some US companies.

The last months I have been working with companies helping them move to SaaS taking advantage of the Cloud, my colleague at Scio consulting, Mike Dunham has written a series of posts “The Cloud, SaaS and the Total Costs of Operations” you can found here: part 1, part 2 and part 3 . This is a developer's point of view.

Microsoft and AWS in a lesser extent, both have information about their products, and how to use them, but one thing that is missing , there are no papers encouraging  developers to change their mind set to develop applications that take advantage of the cloud in terms of business benefits. We, the developers have to start getting more involved in the business side of our companies so we are aware of the challenges, the objectives and the market, how can we design and develop and application that takes our company to  business success if we are not aware of  those “boring” things?

Other thing that I have found, is that, as scrum is invading the startup scene and as companies are being dazzled by the scrum shine, the “fail” line grows faster. Don't get me wrong scrum has its place, but I won't use it for all the projects and I won't use it with all the people. I will use it on projects with people that already know and like each other.

Many architects and developers design and code the application the same way for on premise and cloud environments.  Most of those applications will fail when they need to scale because of their success and the only option to is to scale them up. To run efficiently in the cloud, many apps require changes and rewrites of some parts to run on a web farm.  How can architects and developers design and code for success if scrum and a big picture awareness can't live together?

So what is the solution? It is easy to say we need to design and develop for business success, but not as easy to implement. We have to learn and remember to design and develop applications to scale automatically on demand (elastic), always develop with operations in mind and remember that today ignorance and laziness is tomorrow's nightmare.

Thursday, May 19, 2011

Software development is like cooking


One of the things that I enjoy other than spend time with my family and programing, is cooking, and I was thinking that I may enjoy it just because it's very similar to programing, seriously!.

I have always think about software development as Art, Craft and Science, cooking is the same, the result of you developing or cooking can be considered Art if you are a good craftsman, if you applying science properly and of course if you add creativity and imagination to the process, lets talk about other similarities between software development and cooking.

Software development and cooking process have some similarities:
First you want to fill a need or you want to create something new.

For software development:
- You need to define your goal, your scope, your budget.
- You define high level requirements:
     - You have platforms.
- You make some estimates.
- You develop something:
     - You have pre built solutions, that you can customize.
     - You have tools and frameworks.
     - The Actual development.
     - You test and debug your work.
- You validate your work.
- You publish your work.
- You receive feedback.
- You adjust.

Sample for cooking:
- Dinner/ 6 persons / 100dls
- Appetizer, Soup, main dish, desert:
     - Vegetarian, Meat lover:
          - Mexican
          - Italian
          - Etc.
- Preparation in two hours, 1lb meat, 5 tomatoes, 1 onion. etc.
- The actual cooking:
     - Frozen food.
     - Pans, knife, recipes, frozen vegetables, anything ready to use.
     - The actual cooking.
     - Taste, add salt, add water, etc.
- Ask a family member to taste your dish.
- Serve.
- Receive complements or complains.
- Take note and adjust for next time.

The actual development and cooking process is where a lot of things can make a significant difference, even if you are following a recipe, it's in that part where you can be creative, add or remove  ingredients to the recipe, cook for more or less time, etc. its also the most risky part, you made a mistake and it will be very difficult to fix it without having to start again, also the more you cook, the better you are.

There are also specialties, some developers are better working on the front end and others in the back end, as some chefs are better cooking deserts, salads, etc.

Software development and cooking are not precise, but you can make very good guesses applying some science to your process.

Presentation, consistence, smell, or UI and UX, presentation is one of the most important things for chefs, if the dish is very tasty but lacks of a good presentation, many people will not even would like to try it, the same applies for software development, your product may be a super cool idea, you may be using the latest technology and probably you designed some super fast algorithms but if your product don't have an interesting UI and a very good UX, nobody will use it.

I am pretty sure that there are many other things that make software development and cooking a similar process, but thats all that I can think for now.

Tuesday, April 5, 2011

Hiring developers...

This month we stared hiring developers, by the way, if you are a C# developer with strong knowledge of javascript(jquery nice to have) you can send your resume to hmatamoros@sciodev.com, anyways, we are hiring, I am in charge of most of the technical interviews and this time I am using a different approach for the interviews, let me elaborate:

Most of the times, in most of the companies when they perform remote interviews, the interview goes like:

Interviewer - do you know what is "X"(some obscure or new language feature)? -
Candidate - err (googling the question)...yes, sure!, I used that on my last project -
Interviewer - what does MVP, MVC, MVVM mean? -
Candidate - (googling)...answering.
etc., etc.

Some other companies(us included) use small problems like the famous "bizz buzz", and this is ok, but a developer is not going to be solving simple bizz buzz problems always!, so if you are relying on that kind of tests you are screwed, take a look to:

 for (int i = 1; i < num; i++)
{
     Console.WriteLine(i % 15 == 0 ? "FizzBuzz" : i % 5 == 0 ? "Buzz" : i % 3 == 0 ? "Fizz" : i.ToString());
}

does that tells you if I know OOP, if I know programing principles? does that tells you if I know how to apply some patterns?, of course no!, I also found that some guys that practice for programming concourses solve this kind of problems "easily" but their OOP skills are terrible.

The problem with many technical interviews is that those are not evaluating the skills and knowledge that the individual is going to be using on daily basis, thats why I started to use a slightly different approach, I still use the quick challenges, but I also put them some weird code and I expect them to fix it or comment what is wrong with that code, I also ask them to write some code like a simple repository, and also exercises that help me evaluate their OOP skills, like write a simple game engine.

The results so far are great, previously we hired some people that were not very good programmers, and what happens when you put some pressure on bad programmers? they quit or they just put everybody on trouble and we have to ask them to leave the company, why in the world would I accept a job if I know that I cheated using google on the interview? why would I take the risk of moving to a new city if I know that I am not qualified?, that's something that I will never understand.

Just to finalize, I know that I need to learn a lot of many things, but I am honest and when I don't know something I just said, "I don't know" and then I will put my self to study, I expect the others to do the same, our company always give the people the oportunity to learn, we just use the interview to know if the people is a good match for our culture and to have an idea of their skills.



Tuesday, November 30, 2010

JavascriptMVC



The last week I finally had time to put my hands on http://www.javascriptmvc.com/, I heard about that framework sometime ago but I didn't toke time to play with it, I was a little bit tired about my SaaS ASP.Net MVC framework  that I am working on, so I decided to take a look to that framework.

When I first saw the Javascript MVC video tutorial I was exited about how easy you can create a simple application following the MVC pattern with javascript so I decided to create a very simple application (TODO list) with a WCF REST service connected to it, this is the final version of the app that I created:




After being working with Asp.Net MVC for a while I didn't have any problem following the javascript code and I found the approach very interesting, as the framework is designed to work together with a REST service by default the app runs pretty fast, because small chunks of data are sent and received to/from the service, I know that you can do the same with normal ASP.Net MVC but that is something that usually you do don't do in your firsts projects because usually you are following a simple tutorial that works with normal posts and gets(ajax or no ajax), the advantage of developing the app with Javascript mvc is that you are forced to write your app that way(ajax, json, REST, etc.), also, as the framework helps you writing unit and functional tests so your app will be more robust and you will learn some tricks that you can apply to other applications, of course I have only created a very simple app and only it will be after I create something more complicated that I will know the limitations and trade offs of using that framework.


For the moment you can download the sample app that I wrote here:

I changed the framework's source code a little bit to make the testing faster, now the application detects when its being executed in the context of a unit or functional test so all the ajax requests are emulated and the app works only with data in memory, also I allowed the user to manually set the app to run in test mode so you don’t be messing with real data when you are developing, testing and debugging your app and tests.


These are some tricks and gotchas that I found when I was developing the wcf REST service:

  • You cannot make ajax post/delete/put request to other domain, I knew this one but I wasted a couple of hours because I just forgot it, well, you can do it with some tricks but not naturally.
  • If you want your service to return real json and not a string that represents a json object you should not return a string in your web method, let me elaborate, almost all of the tutorials and comments on internet just said that you have to add the following parameters to your WebInvoke attribute: BodyStyle = WebMessageBodyStyle.Bare, ResponseFormat = WebMessageFormat.Json  but that is not enough others said that just setting the correct ContentType will do the trick, but that does not work either, and that’s because no matter that you are returning a json object (as string) the response will be wrapped so your return value will be wrapped as if it was a normal string, this is not actually a real problem since you can then convert that string into json object(s) in js with a simple instruction like: jQuery.parseJSON(StringData) but as you can imagine, if your data is very large the conversion will take a while and the browser will blocked by this conversion, also, why convert the data if we can just send it correctly?, to make it work, you service has to return a Stream and you should write your json serialized object into that Stream.
  • Serialize your object with the DataContractJsonSerializer instead of the JavaScriptSerializer, this way you will have complete control on how your object is serialized.



This is the structure (not detailed) of the sample solution:

  • The root folder contains the wcf service and other classes that I use in the service's code.
  • The RestServiceCode contains code required by the Rest service.(this note was added by captain obvious)
  •  documentjs, funcunit,jquery and steal folders are javascript mvc stuff.
  • todo folder, this is where the javascript mvc app resides, I suggest that you take a look to the video tutorial so you are familiarized with the structure of an javascript mvc app.
  • The DBScripts folder that contains one big script to create the db and populate a few tasks.



Running the sample code:

  • Create a database called ToDoDB (use that name so you don’t have to change the script).
  • Run the script included in the source code.
  • Modify the web.config and the app.config (tests project) so it points to your new DB.
  • Run the app, if you don’t see a thing, check that your browser its pointing to this url:http://localhost:19978/todo/todo.html  (or the port that is configured in your machine)
  • If you want to run the app in test mode just add the query string test=true, so the url will be something like: http://localhost:19978/todo/todo.html?test=true 
  • To run the unit and functional tests follow the instructions on the video tutorial.
  • That’s all.



Please notice that the app does not follow all the best practices and I just wrote two normal MS tests to test the service, the intention of the sample code is not to teach best practices but to show a javascriptmvc working app .



Comments and questions are welcome.

Thursday, November 4, 2010

Data Access with Cheetah Framework.



  As I mentioned in my previous post, I am working on a Framework(Cheetah Framework) that will help developers writing SaaS applications with asp.net MVC, in this post I will be talking about how the Cheetah Framework help developers with the data access for SaaS applications.
First of all, usually there are three main ways that the data is stored on the server:

  1. Isolated Schema, isolated database.
  2. Isolated Schema, shared database.
  3. Shares schema, shared database.
For more information about advantages and disadvantages about each model you can go here


Cheetah Framework uses the third option, i.e. shared schema, shared database, to make it work, Cheetah Framework needs you to follow some simple rules when creating your database, oh and by the way, Cheetah Framework supports SQL server and SQL Azure, once you have your database defined, you need to configure just one connection string and update one single file(no single line of code involved) and Cheetah Framework takes control from there, just compile your project and you will have access to functionality that was generated for you.

Cheetah Framework will automatically filter the data based on the active tenant so developers will work with the data as if they were developing a single tenant application, also Cheetah Framework has built in support that allows the tenant to extend any table in their database, so, for instance, developers can define a base table "Products" with a fixed set of fields and each tenant will be able to extend the "Products" table to fit their needs, in terms of code, developers can access those extended fields directly as if they were part of the "Products" table, something like:

NewProduct.MyCustomField = "test"

This feature is also useful when creating verticals, lets said that you are creating a  Time Track SaaS application, you can define a vanilla app and then define extended fields for specific verticals, like Time Track for Developers, Time Track for Doctors, Time Track for teachers, and so on, also each vertical's tenant will be able to add their own custom fields.

The following is an example with the current version of the Cheetah Framework that was added to a vanilla MVC application:
This is the aspnet_Users table: 











As you can see the field "FirstName" is not part of this table.
This is the basic code that you will need in the controller:

And this is a simple example of  the View :
 


As you can see, you use the extended field "FirstName" as it was part of the original object, any extended fields can be accessed that way.


Well, thats all for now, in the next post I will continue talking about how the data is accessed and other things that Cheetah Framework does for you.