My.Generation -or- CodeSmith

Anything that doesn't fall into the defect or enhancement categories

My.Generation -or- CodeSmith

Postby Zarehd on Thu Oct 16, 2008 5:26 am

I have been evaluating My.Generation and CodeSmith to offer a recommendation to our development team and I want to share some of my findings with the My.Generation community in order to provide some feedback from the perspective of a potential user.

I found both products to be strong in terms of flexibility, extensibility, and functionality. Both support a large number of packaged templates like dOODads, nTiers, and others. Both have good foundational frameworks, and both are capable of handling the basic and advanced functions for generating code from templates based on meta data from a database. My.Generation had broader support for native drivers and, as an open source product, has the greater opportunity for enhancements in this area. Both products support SQL Server, Oracle, and MySQL -- the basic three! CodeSmith had a nice feature in a user's ability to define template properties right within the template code. On the other hand, My.Generation's support for creating a custom UI for a template is a great unmatched feature. Suffice it to say that both products earn a respectable score in most areas.

My biggest complaint equally for both products revolved around the code editor and IDE. Both products support syntax highlighting, but the Inellisense-like feature is weak and could be much improved to help developer productivity in both products. Keyboard layout (key combinations, shortcuts, etc.) which directly relates to usability, was a big challenge for My.Generation, especially the lack of support for keyboard shortcuts for switching between templates. In fact, it seemed far too often one had to reach for the mouse because that was the ONLY way to perform a certain function! Although the CodeSmith editor and IDE had some issues, it had far more fit and finish and was more polished -- closer to that of Visual Studio 200x. Compared to the My.Generation editor, the CodeSmith editor had much higher quality, user friendliness, and general usability -- especially from the keyboard. Perhaps that's my bias, but CodeSmith's closer resemblance in keyboard layout, shortcuts, etc. to Visual Studio was a major factor.

The open source nature of My.Generation is a major factor in its favor. On the other hand, the polish and resemblance to Visual Studio give CodeSmith a clear edge. My conclusion is that, for developers like me who are keyboard oriented code junkies, the editor makes a very BIG difference and My.Generation severely lags in this area. In the end, all else being equal -- and I feel they are in general -- the editor and IDE are the deciding factor between the two products.

I would love to hear some feedback from the community -- especially with regard to my experience with the editor and IDE.

Thank you.
Zarehd
Lurker
 
Posts: 6
Joined: Thu Oct 16, 2008 3:45 am

Re: My.Generation -or- CodeSmith

Postby CameronB on Thu Oct 16, 2008 10:41 pm

Interesting insight.

This in fact quite reflects my own experiences with MyGeneration.

We use VisualStudios 2008 (C#) and SQL 2005 is our target DB.

The approach we have taken is that we do not actually use the main UI for MyGeneration at all. All our templates are very empty; they just load and call methods from within our own libraries (templates)

All the work for the templates we create is done within visual studio. We compile our libraries to the MyGeneration directory, and then run them using the zeuscmd.exe passing in the name of the template we need.

In this way, we have effectively got the same IDE that we use to build all of our apps, i.e Visual Studios.

We get all the important intellisense features and debugging a template is a breeze. Just hit play in VS.

In essence, we effectively worked around what we saw as the shortcomings of MyGen to really leverage off what I personally believe to be a fantastic open source community driven product.
CameronB
Corporal
 
Posts: 21
Joined: Sun Sep 28, 2008 10:46 pm

Re: My.Generation -or- CodeSmith

Postby justin.greenwood on Mon Oct 20, 2008 2:53 am

There is no doubt that MyGeneration needs a lot of work to become as polished as CodeSmith. The primary reason is that there is lack of interest when it comes to contributing to the project. I am pretty much the sole developer and I am a very busy guy! Mike Griffin is 100% on EntitySpaces and he's even got his own built in code generator with EntitySpaces 2009, so I see him pretty much taking another step further back away from MyGen. However, in my spare time I am still hacking away a few hours here and there at this project. If there are specific problems with keyboard shortcuts, etc - you should at least post a feature request or bug report so I can get it on my list. I am working my way through bugs and feature requests as well and things I need for work. Yes, I actually use it at work every day. In fact, a coworker of mine just added a new FoxPro MyMeta provider yesterday! As consultants, we run into all kinds of stuff and there is almost always a reason to pull out the ol' code generator.
User avatar
justin.greenwood
Site Admin
 
Posts: 441
Joined: Sat Apr 03, 2004 6:10 am
Location: Indianapolis, IN

Re: My.Generation -or- CodeSmith

Postby CameronB on Mon Oct 20, 2008 2:59 am

Justin,

when I get over the hump of the current project I'm on, I'm more than happy to get in there and contribute.

Can't stop singing the praises of this little beastie!

Cheers - and much praise and thanks.

Cam
CameronB
Corporal
 
Posts: 21
Joined: Sun Sep 28, 2008 10:46 pm

Re: My.Generation -or- CodeSmith

Postby Zarehd on Tue Oct 21, 2008 4:32 am

Justin,

Thanks for your feedback. I can definitely appreciate your point about the time and resource constraints. I am heavily involved in two large corporate projects myself. I hope I didn't offend you with my observations, and I'd be glad to offer as many feature requests / bug reports as I can think of or find. Just to repeat what I had said before, I think My.Generation does a terrific job at code generation and it appears to be very flexible and extensible. There's lots of good to say about this tool. My ONLY complaint was with the editor, perhaps because I'm jaded from using Visual Studio! My hope was that the feedback would be useful in guiding the general direction of the effort in the project. It stands to reason that the number of users AND contributors will grow as the usability of the tool improves. So my intention was to be helpful, not to criticize. With that said, let me throw out a couple of specific feature requests that can be put on the the old TODO list:

    - Keyboard shortcut to iterate through open template documents. CTRL+TAB is the standard in Windows environments but right now CTRL+TAB and CTRL-PGUP/PGDN do the same thing -- iterate trough the tabs of the current template document;
    - Keyboard shortcut to jump to the declaration or definition of an item;
    - Brace matching;
    - Code collapse/expand feature (tree-like structure in the editor with +/- signs next to collapsible code);
    - Keyboard shortcuts for code collapse/expand feature;
    - Enhanced Intellisense-like feature that shows method overloads and their signatures;
    - Keyboard shortcut for inserting predefined code snippets;

There are probably much more that I take for granted daily as I use Visual Studio, but I'll try to make a mental note of them whenever possible!

Also, while the library of templates available from the site is a VERY rich source, I feel the following would be very helpful to newcomers:
    - A getting started guide;
    - Samples of creating custom templates;
    - More complete / contextual samples of using the ZeusCmd;
    - Usage patterns and samples in the documentation;
    - Deeper explanations / discussions of subjects, such as:
      - MyGeneration framework
      - Template options
      - ZeusCmd
      - DnpUtils
      - Custom mapping
      - Custom template UI

I'm sure a perusal of the forums could add to this list too.

Anyway, I hope that helps you. Again, I think this is a great tool and I hope it can acquire the polish it deserves. Keep up the great work.
Zarehd
Lurker
 
Posts: 6
Joined: Thu Oct 16, 2008 3:45 am

Re: My.Generation -or- CodeSmith

Postby Zarehd on Tue Oct 21, 2008 4:40 am

Cameron,

Thank you for your reply. I don't quite understand how you are using the combination of Visual Studio, MyGeneration libraries, a template file, and the ZeusCmd together. Can you perhaps explain in more detail or maybe post a simple but complete sample?

Thank you in advance.
Zarehd
Lurker
 
Posts: 6
Joined: Thu Oct 16, 2008 3:45 am

Re: My.Generation -or- CodeSmith

Postby CameronB on Tue Oct 21, 2008 5:25 am

Zarehd,

unfortunately I don't have an easy small example I can post.

Hopefully though, this may give you an idea.

The Template code looks something like this....
Code: Select all
<%#DEBUG%><%#REFERENCE System.Windows.Forms.dll,MyTempalate.dll,System.Drawing.dll,CslaTemplate.dll%><%#NAMESPACE System.Windows.Forms,System.Drawing,System.Collections.Generic,MyTemplate %><%
public class MyTemplate : DotNetScriptTemplate
{

   protected MyGenerator aTemplate;
   protected MyScriptSetting ss;

    public MyTemplate(ZeusTemplateContext context) : base(context)
    {
        if (context.Objects.ContainsKey("DnpUtils"))
        {
            DnpUtils.SaveInputToCache(context);
        }

        //Set MyMeta options in order to make sure the correct language and data type
        //generator are used.
        MyMeta.Language = "C#";
        MyMeta.DbTarget = "DbType";
   ss = new MyScriptSetting(input, MyMeta.Databases, DnpUtils);
        aTemplate =
            new MyGenerator(input, MyMeta, DnpUtils, output, ss);
   
    }
         
   public override void Render()
   {
      aTemplate.Launch();       
   }
}


The Interface code looks something like....
Code: Select all
<%#DEBUG%><%#REFERENCE System.Windows.Forms.dll %>
<%#REFERENCE MyTemplate.dll %>
<%#NAMESPACE System, System.Text, System.Collections, Zeus, Zeus.UserInterface, Zeus.DotNetScript, MyTemplate.Interface %>

public class GeneratedGui : DotNetScriptGui
{
   protected MyUI aInterface;
   
   public GeneratedGui(ZeusGuiContext context) : base(context)
   {
      if(context.Objects.ContainsKey("DnpUtils"))
      {
         DnpUtils.ReadInputFromCache(context);         
      }

      aInterface =
            new MyUI(input, MyMeta, DnpUtils, ui);      
   }   

    public override void Setup()
    {
        aInterface.Launch();
    }
   
   public void cmbDatabases_onchange(GuiComboBox control)
   {
      aInterface.cmbDatabases_onchange(control);
   }
      
}


And then there's my Assembly - which is the template. (MyTemplate.DLL in this example)

The code in the assembly looks something similar to the code generated when you look in MyGeneration at the Template Source and Interface Source tabs for any standard MyGeneration template.

Sorry I can't be any more of an immediate and direct help... time constraints and project deadlines!

Cheers,

Cameron
CameronB
Corporal
 
Posts: 21
Joined: Sun Sep 28, 2008 10:46 pm

Re: My.Generation -or- CodeSmith

Postby Zarehd on Wed Oct 22, 2008 4:07 am

Cameron,

That's perfect. It's the missing link I was looking for. If I have it right, the real template is actually a class library project in VSNET and then it's referenced in the basic template in MyGeneration where it's instantiated and exercised by that template. Brilliant!

Is it possible to debug in VSNET and in My.Generation? If both, which is better, more productive?

Thanks for prompt reply, BTW :)
Zarehd
Lurker
 
Posts: 6
Joined: Thu Oct 16, 2008 3:45 am

Re: My.Generation -or- CodeSmith

Postby CameronB on Wed Oct 22, 2008 5:13 am

:D ~Ding!~

You nailed it.

As I mentioned earlier, we only debug using Visual Studios. We never actually go into MyGen at all.

:idea: I suppose the key is setting up your projects properly.

Ensure you build to the C:\Program Files\MyGeneration13 directory

Properties for Debug
  • Start External program = C:\Program Files\MyGeneration13\ZeusCmd.exe
  • Command line arguments = -t "C:\Program Files\MyGeneration13\Templates\MyTemplate.csgen"
  • Working directory = C:\Program Files\MyGeneration13

Debug and be merry
CameronB
Corporal
 
Posts: 21
Joined: Sun Sep 28, 2008 10:46 pm

Re: My.Generation -or- CodeSmith

Postby Zarehd on Thu Oct 23, 2008 4:41 am

~ding~ is right :P

I just finished my first template based on your method and stepped through it with the debugger. Fantastic!!! :D

Visual Studio is the ideal medium for this. The rest is just learning the MyGeneration and ancillary frameworks. :roll:

Thank you so much for the help.
Zarehd
Lurker
 
Posts: 6
Joined: Thu Oct 16, 2008 3:45 am

Re: My.Generation -or- CodeSmith

Postby CameronB on Thu Oct 23, 2008 5:26 am

Glad I could help.

I can't help myself, so I just have to ask....

Given what you know now, how does that change your evaluation/comparison?

Cheers!

Cameron
CameronB
Corporal
 
Posts: 21
Joined: Sun Sep 28, 2008 10:46 pm

Re: My.Generation -or- CodeSmith

Postby Zarehd on Fri Oct 24, 2008 5:43 am

I thought you might ask :D

I've written a few real-world (medium complexity) templates using CodeSmith and I found the asp.net style coding fairly easy, but debugging was a time-consuming trial-and-error business. Integration with the VSNET IDE was nice, but I didn't exercise that feature much. I don't know if it's a game changer for anyone -- it might be for some.

With this approach to developing MyGeneration templates, writing 'output.write' style code will probably be a bit less intuitive but I suspect the ability to use Visual Studio for editing and debugging will provide a MAJOR productivity boost, especially when writing complicated, highly flexible templates.

So while I reserve final judgment (until I can write some real-world templates with MyGeneration,) I'd say my opinion has changed VERY favorably towards MyGeneration :D

As an aside, I think your contribution to this thread has made the difference -- certainly for me and hopefully anyone else that reads these posts.

You deserve a MyGeneration 'Friendly and Helpful User' award, or surely some form of recognition... hint, nod, wink :D

Definitely a great big THANK YOU from me :D

So I'm off to write some templates with MyGeneration -- time permitting, of course.

I will probably have more questions as I dig deeper into this thing, and I may even be back to post more evaluations :D

Thanks again Cameron and Justin. Keep up the great work :D
Zarehd
Lurker
 
Posts: 6
Joined: Thu Oct 16, 2008 3:45 am

Re: My.Generation -or- CodeSmith

Postby CameronB on Fri Oct 24, 2008 6:06 am

Cheers mate.

Thanks for the vote of confidence.

Another hint....

In our template classes, we've written code to shortcut things like output.write with the following little helpful gems..
Code: Select all
        public void write(string myString)
        {
            output.write(myString);
        }

        public void write(string myString, params object[] arg)
        {
            output.write(string.Format(myString, arg));
        }

        public void writeln(string myString)
        {
            output.writeln(myString);
        }

        public void writeln()
        {
            output.writeln(String.Empty);
        }

        public void writeln(string myString, params object[] arg)
        {
            output.writeln(string.Format(myString, arg));
        }


we've also done the same with the autoTabLn functions.....

Also, if you are running the templates and an exception occurs..... make sure your template captures all exceptions and call something like below....
Code: Select all
        private void DisplayException(Exception ex)
        {
            string anErrorMessage = "1 - " + ex.Message;
            string aStack = ex.StackTrace;

            Exception inner = ex.InnerException;

            int i = 2;
            while (inner != null)
            {
                anErrorMessage += string.Format("\r\n\r\n{0} - {1}", i, inner.Message);

                aStack += string.Format("\r\n\r\n == Stack {0} == \r\n {1} ", i, inner.StackTrace);
                i++;
                inner = inner.InnerException;
            }

            System.Windows.Forms.MessageBox.Show(anErrorMessage + "\r\n\r\n ==Stack Trace==\r\n\r\n" + aStack,
                this.GetType().ToString() + " template Initialisation error",
                System.Windows.Forms.MessageBoxButtons.OK,
                System.Windows.Forms.MessageBoxIcon.Error,
                System.Windows.Forms.MessageBoxDefaultButton.Button1,
                System.Windows.Forms.MessageBoxOptions.DefaultDesktopOnly);
        }


It's ugly, but it helps.
CameronB
Corporal
 
Posts: 21
Joined: Sun Sep 28, 2008 10:46 pm

Re: My.Generation -or- CodeSmith

Postby justin.greenwood on Fri Oct 24, 2008 2:16 pm

Interesting stuff guys. I've added many of your suggestions/ideas to the todo.txt file on sourceforge. Hopefully we'll get some of that stuff into the next release. There are already a ton of new features and fixes coming.
User avatar
justin.greenwood
Site Admin
 
Posts: 441
Joined: Sat Apr 03, 2004 6:10 am
Location: Indianapolis, IN


Return to General Questions or Comments

Who is online

Users browsing this forum: No registered users and 3 guests

cron