Stories on leadership, education, and innovation 

formats

theClubhou.se: Growing an Awesome City through a Culture of Making

Check out https://www.facebook.com/theClubhouseAugusta

Maker spaces are starting all across the country providing a welcoming environment for tinkering and inventing.  In these spaces, you’ll find programmers building cool apps.   In the same space, you might find a class of young people learning how to build their first Arduino project.  You might find an inventor prototyping components for a new product using the 3D printer.   In this past week, I had an opportunity to experience a vibrant Maker community in Augusta, Georgia called theClubhou.se.   In this post, I want to share a few ideas from this community for growing your city.

How does theClubhou.se Support the Augusta, Georgia Community?

  • Supporting Young Makers: The community actively encourages young people to appreciate science, technology, engineering, art, and math through their “Young Makers” program.   Class topics can include web programming, Manga, Arduino programming, 3D printing, and much more.  Mr. Charles Gantt shared his experiences organizing and leading some of their Young Maker events.  At times, kids have a hard time feeling welcome with their peers in a traditional school environment.   Charles has been encouraged that their Young Maker events often provide an environment where these kids feel a sense of welcoming and belonging.  (Very cool!)   The kids can really get into their building projects.   In many cases, the students don’t want to go home.
  • Creating Jobs: The community attracts people engaged in tinkering and technology.   Some community members who met through the organization have started building start-ups in Augusta together.   (Check out http://www.txtcam.com)   In other cases, a job seeker meets a potential employer through an event.  In this case, theClubHouse.se acts as a social connector for job creation.
  • Community Innovation: I would encourage you to check out the social media feeds on Twitter and FaceBook to see the output of the group.   In the past weekend, the community participated in the international NASA space apps challenge.   It’s fun to see the new ideas and projects from people who are passionate about technology and helping others be successful.   Great ideas need to be spread and shared.   The community has hosted TedX events in their space.
  • Supporting the “Cool” vibe of Augusta:   I think it’s awesome that the community is actively leading the http://superhappyaugusta.com/ block party in late May.   The event helps to connect the community of artists in Augusta to the community of hackers.   Very fun and cool!
How do you support such an awesome Maker community?
Charles mentioned that everyone in the community wants to make something that they can feel proud of.    I think these citizens of Augusta, Georgia have built something that is very special: a welcoming and innovative Maker community.   I appreciated Eric Parker, Grace Belangia, Charles J Gantt, and Vinnie Ingallinera for sharing their experiences.   I wanted to share some of their tips for building a Maker community in your area.
  • When you’re building your own space, do not immediately start purchasing expensive equipment.   Focus on building the community.   With the community feedback and support, collaboratively start making tool purchase decisions.
  • The community is generous.   In many cases, the community will share personal resources for the benefit of the community.
  • Partner with user groups and community groups in your area.
  • Encourage of a culture of pride.   The community should be proud of EVERYTHING it does.   This applies to teaching, building a culture, or making cool stuff.
  • Find ways to serve your greater community.
  • Find Makers.   Help those Makers become successful in their passion.
  • Encourage a DEMO culture.   If you spend time in the community space, at the end of the day, you are encouraged to share the product of your work with the community.    It’s kind of like “show and tell” for Makers.   It helps others to learn from your experience.  It might trigger other innovations too.
  • How do you financially support the space of the community?
    • theClubhou.se is supported through monthly memberships.
    • The community regularly sponsors events.   In many cases, the events are sponsored by community partners and companies.
    • In the future, the community will be supported by grants.
    • In the future, the community will be supported by co-working space membership fees.
I want to express my thanks to Eric, Grace, Charles, and Vinnie for taking time from their busy schedules to share the story of theClubHou.se .   I also want to thank Brent Lanford from Middle Georgia Regional Commission for inviting me to tour this community space.  It was SO fun taking a road trip with him and his team to visit this maker space.   Thank you Kristi and Robert for the great road trip conversation.   I’m excited to work with Brent and other community leaders to grow a Maker culture in Macon and Warner Robins, Georgia.
People to follow from theClubHou.se
  • Eric Parker @ep_aia: architect+entrepreneur, designing a box where the outside is in, and then thinking outside the box again @HackAugusta @_Clubhouse
  • Grace Belangia @GraceBelangia: The girl in green. TEDx Organizer, HACKAugusta, theClubhou.se, triathlete, event planning. Connecting, communicating and collaborating with your community.
  • Charles J Gantt @CharlesJGantt: | Tech Journalist | Reviewer | Maker | Drupal Developer | Gamer | Writer | Photographer | Kayaker | 3D Printer | DIY Electronics Geek | Tech Junkie
  • Vinnie Ingallinera @TonyStarkWannaB: This wanna be Tony Stark is masculine, malevolent,and mysterious; with a penchant for both the adventurous and intriguing.

 

 

 
 Share on Facebook Share on Twitter Share on Reddit Share on LinkedIn
No Comments  comments 
formats

5 Free E-Books on Scrum and Agile Testing

For teams that do creative work, Scrum has become a popular management framework to help improve team focus and provide a disciplined pattern for continuous improvement.  Working with teams that use agile/scrum, it has been fun to see how the leadership and meeting patterns in scrum help improve positive communication in the organization.    I don’t present Scrum to you as “THE” perfect solution for running your projects.   No project management framework is perfect.   I,however, do believe that Scrum helps your team and organization discover ways to improve together.     As Ken Schwaber would note, Scrum has just enough structure to help your team start the continuous improvement process.

To help support some of my friends who are just getting started with Agile development,  I wanted to collect together a few free e-books that review Scrum, Kanban, and the engineering test practices linked to agile.    As I continue to improve my thinking around agile leadership, I believe it’s important to help our teams learn how to engineer software so that it’s easy to test and change.    Creating software that’s easy to test and change starts with thoughtful design.      

InspiredToEducate.NET Posts 

 
 Share on Facebook Share on Twitter Share on Reddit Share on LinkedIn
No Comments  comments 
formats

Visionary Kickstarter Projects to Inspire Future Makers

piBot

Pi-Bot: The Next Great Tool for Learning Arduino Robotics! The Pi-Bot is a uniquely designed (and affordable!) complete robot kit for anyone interested in building and programming robots!   Please consider supporting this team of college students supporting STEM education through their robotics innovation.  It looks really cool.

AgIC Print – Printing circuit boards with home printers AgIC transforms a home printer into a circuit board manufacturing equipment. The fastest and cheapest way to print circuits.

ScratchJr: Coding for Young Kids : Coding is the new literacy. With ScratchJr, young children (ages 5-7) learn to program their own interactive stories and games.

The MicrobeScope: The MicrobeScope, a powerful pocket-sized microscope, reveals the hidden world of microbes and shares video via iPhone compatibility.

 

InspiredToEducate.NET Posts 

 

 
 Share on Facebook Share on Twitter Share on Reddit Share on LinkedIn
No Comments  comments 
formats

Join the National Day of Civic Hacking

Hack For Change

Are you a programmer, community leader, or designer wanting to make a difference?  Mark your calendars for May 31 – June 1, 2014 for the National Day of Civic Hacking, a fun weekend of community service using design, programming and technology.  Whether you’re a novice or expert, all are welcome!

Why Join the Civic Hacking Day

  • Contribute to Your Community: The news is filled with challenges and problems that face our nation, state, and local communities.   On this weekend of community service, technologists across the nation join forces to grow our communities and prototype solutions.
  • Learning by Doing:  I greatly appreciate that the “National Day of Civic Hacking” is open to everyone!  You do not need to be an expert in technology to be a part of the event.   The event is an fruitful opportunity to learn from community designers, entrepreneurs, community leaders, and programmers.   Since the event only lasts one or two days,  teams design very simple solutions to a focused challenge.   The weekend time bounds create an intense and fun learning experience. You learn innovation by doing it.
  • Network with Creative Designers, Programmers, and Leaders: Creatives love to share their craft.   The Civic Hacking Day provides an opportunity for you to get inspired by new ideas, new design techniques, novel tools, and positive social connections.
  • Gain Insight into Community Challenges: The event shines a light on civic challenges and open data.   Collaborating with other innovators in your area, you get to study of problems in your community that YOU care about.
  • Experience the Creative Process:  The 1 or 2 day time box forces teams to explore simple solutions.   Teams will need to focus on one problem, brainstorm potential solutions, prototype a solution, and pitch the idea to your peers.   This is a weekend of action and focused creativity.
My Experience
Last summer, I had the opportunity to participate in my first civic hackathon in Macon, GA.  I spent the weekend prototyping a social network site to encourage and support student entrepreneurs to design a business plan, prototype ideas, and learn by experimentation.   During the weekend of building the site, I learned a lot with my team.  ( check out this post for more details )   It was fun building a social network.   We, however, struggled with keeping our idea focused and communicating the vision.   After supporting the community site with blog posts for months, I decided to pivot the idea for the community site.   While business minded high school and college students exist, these students are a very small minority.   I still believe that it’s important to give hope to high school and college students.   I’m still troubled when some of my young friends graduate from school and struggle to find work.   My personal goal was to give students inspiration and help them discover that they have options.  So, In the spirit of the lean startup, we created a minimum viable product(MVP), we tested it, and I learned lots of lessons.  

As I reflect upon the past year, I feel like I’m still accomplishing the vision of Changella website by mentoring our local Mercer University Google Developer Group.   I love teaching the craft of software and web development.   It has been fun to challenge our group to think about software as a means of positive change.   Technology is not an end.

 

How Do I Get Involved?

To learn more about the event get involved, visit the following website.   Events are organized across the country.

http://hackforchange.org/

What’s a Hackathon?  

InspiredToEducate.NET Posts

 

 

 

 
 Share on Facebook Share on Twitter Share on Reddit Share on LinkedIn
1 Comment  comments 
formats

Engaging Young and Old Inventors with MakeyMakey: Re-invent the World!

Makey Makey

As artists and makers, we enjoy the process of creating something new from something old or familiar.   The Makey Makey makes this possible.   Makey makey is a USB device for your Mac or PC enabling makers of all ages to experiment with human computer interaction and inventing.   The Makey makey interface enables you to design playful circuits and switches.   Our family just received our device last night and the kids LOVE it!   The following video describes the Makey makey in great detail with example experiments.

On our first evening with the device, we built the following experiences:

  • Tin Foil Target: Using two pieces of tin foil, we created a really simple target.   We connected the “earth/ground” wire to one piece of tin foil.   We connected the other tin foil piece to the space bar trigger.   Using Scratch, we created a simple program that mades cat noise when the user pressed space bar.  We suspended the pieces of tin foil so that they had a slight gap between them.   When the tin foil touches by the boys throwing balls at it, the computer triggers the cat sound.   This was a big hit with the kids.
  • Spoon Piano: Using the online piano on MakeyMakey.com, we constructed a musical experience using 5 spoons.
  • Spoon Drumkit: Using Scratch and spoons, we created a small drum kit. 
  • Play-Doh controlled Minecraft: The kids wanted to use play-doh for one of their creations.   We designed a small controller so that you can move around Minecraft.

We did all of these experiments in 2 or 3 hours of playing.  It was tons of fun for me and the kids.   We’re looking forward to doing more tinkering!  Looking for more project ideas, check out the MakeyMakey website.

 
 Share on Facebook Share on Twitter Share on Reddit Share on LinkedIn
No Comments  comments 
formats

Why does this Programmer Enjoy Learning from Teachers?

Teacher helping student

While I work as a professional software engineer and scrum master, I have become passionate about creating environments of learning and becoming better as a teacher. While some of my geek or software buddies believe that I’m weird, I believe that my internal drive to learn more about education and learning is meaningful. For our readers, I wanted to share a few quick reflections regarding the impact of my study of great teachers and leaders.

1. My wife is a teacher: My wife Dr. Sarah Rosario works as a college professor teaching biology and microbiology.    At the Rosario dinner table, it’s common for us to share the high and low points of our day.    It’s really hard for us to avoid the topic of education since Sarah is growing young minds in college daily.   It’s great to hear Sarah connect with her students and help them grow.   It’s difficult to hear the times that her students let her down.   Sarah works REALLY hard to grow her students and create success for her students.  I guess… I study education technology and learning to help support my wife in her career.

2.  I’m a Dad. Teaching is my job: We have wonderful kids.   We have been blessed with good teachers in our schools so far.   As I study blogs on educational technology,  I am often reminded of my core responsibility to be a teacher to my kids.   As I have studied the book “Invent to Learn”, Makers movement in education, and project based learning, it has been fun to apply some of these ideas with my family.   Sarah is really good at getting the family to be outside and connect with learning in nature.   As parents, we are trying to grow as teachers.

3. Teaching gives me joy:  It’s one thing to write a cool piece of software and get it working.   It’s completely AWESOME when I see my team members growing, learning, and succeeding in writing well crafted software or using Scrum.    It’s cool to see junior team members take small “nuggets” of programming techniques I’ve taught them and see them teaching others.  Teaching creates more teachers.

4. Learning creates change: During a financial peace class, my wife and I got this precious tip from Dave Ramsey: Do business with people who have the “heart of a teacher.”   For some reason, that advice really stuck with me.   That phrase inspired me to make teaching a central strategy for growing success for my team and our communities.   It has been fun to coordinate a small professional learning group at work to help us become more innovative and serve our communities more.
( Check out this blog post on the book club) We are discovering that excellence in learning leads to excellence in culture.

5. Technology does not guarantee learning: In agile culture, we have a wonderful phrase: “People are more important than processes and tools.”   As I have studied teachers adopting educational technology, this insight is very clear and repeated.    Even if you give your students the best mobile devices and apps, I does not mean that your students will grow and learn.    It has been fun to study how great teachers plan,  give selflessly, organize games, and environments where students can have personalized learning and coach their students to move forward.

6. Machine Learning:  One of my hero’s from the machine learning research community is Sebastian Thrun.   His research team at Stanford won the DARPA grand challenge for driving an autonomous car across a desert maze.   This was an amazing scientific achievement in computer science.   I’ve noticed that people who love machine learning also love human learning.   Mr. Thrun has been a key leader in building UDacity , a start-up seeking to democratize higher education.     I love machine learning as well.  I think it has been important for me to study the learning of children to help focus my thinking in machine learning research.

7.  I am thankful:  I have been VERY blessed by my parents and my teachers.    The blessing of great education from my teachers and parents is a debt that I can never repay.   I hope that the small little lessons that I share on InspiredToEducate.NET help me pay forward the gifts given to me.   Perhaps a small lesson in leadership might transform a business.   Perhaps a young adult discovers a new career direction by learning how to code.   Perhaps a teacher discovers a new way to engage his or her students in learning how to learn by learning to program.

How can I help you?

The Wall Street Journal recently wrote a piece “Who Needs to Know How to Code.”  The article describes some of the benefits for kids and business executives to learn how to code.   While every business leader or kid does not need to become a developer like me, the article suggests that all people benefit from learning the thinking styles connected to coding: critical thinking, experimentation, tinkering, technical communication, etc.   By design, I would like this blog to serve anyone who wants to learn to code, design, and make.

I would like your help to focus the content of our blog.

  • What topics in code or maker education would serve your students?  What would help you as a teacher?  What would help you as a parent?  
  • What topics in learning to code would help you take your career to the next level?

 

 InspiredToEducate.NET Posts

 

 

Photo by http://www.flickr.com/photos/kathycassidy/8522478858/sizes/m/in/photostream/

 
 Share on Facebook Share on Twitter Share on Reddit Share on LinkedIn
No Comments  comments 
formats

Designing Software that’s Easy To Test

Published on March 11, 2014 by in agile, programming

As programmers, we desire to create well crafted software that delights our customers.   Because we care about the long term maintainability of our code, we aspire to craft our code well.    In the ideal case, future programmers should find it easy to change our code while avoiding errors and regressions.  How do we accomplish this vision?

I wanted to share one of my favorite agile software engineering techniques: test first design.  (TFD)  In a classical model of software development, special attention for testing comes at the end of the project.    In agile culture, we aspire to test our software early and often throughout the project.   “Test first design” encourages programmers to write test cases for software units (“classes”) continuously through the life of the project.    For large software applications and games, it becomes more important to keep our software loosely coupled and easy to test.   Think about the components of your software as Lego blocks.   In the ideal case, the various components of your application should be designed to connect together.   At the same time, we should have the ability to test the behavior of each class or “lego block” in isolation.  Does each block function well?   If we snap all the blocks together, does the system behave as expected?

Software as lego blocks

In the following JavaScript code sample, I have presented a qunit test case to help introduce the idea of “test first design.”    The “MathUtil” class has a method for calculating the distance between two points.  In the “arrange” section of the code, we construct the variables and objects of the test case.    After we execute the method under test, we assert that the method “GetDistanceBetweenPoints” returned the correct answer.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
test( "MathUtil__GetDistanceBetweenPoints__Success", function() {
//arrange
var util = new MathUtil();
var x1 = 0;
var y1 = 0;
var x2 = 5;
var y2 = 5;

//act
var result = util.GetDistanceBetweenPoints(x1,y1,x2,y2)

//assert
ok( result == 7.0710678118654755 );

});

Unit test frameworks exist in every computer language.   The process for test first design is pretty simple.   Write a test that fails.   After the test case compiles/parses correctly, write just enough code to make the failing test pass.    You are encouraged to write the most simple code that could possibly make the test case pass.     With test cases passing, take a little bit of time to clean up or improve the code.   That’s it!   Repeat the process as much as you like.

TDD cycle

By collecting your test cases over time, you can build a suite of test that will help you discover regressions in the system.    I love that this coding methodology helps you find semantic errors in your code quickly.   What are some other benefits of using “test first design?”   Here are just a few:

  • Find bugs early:  In general, the longer a bug remains in a code base, the more complex and expensive it will be to remove it.    ”Test first design” helps you discover and remove defects early.    I don’t want to over sell this methodology.    You still need to use manual, scenario based testing, demo sessions, and peer reviews to detect and remove other classes of defects.  
  • Designing Lego blocks of working software: In test driven development (TDD), we are trying to test each method of a class in isolation.   This pattern of construction encourages us to design our software in baby steps.    The baby steps tend to be loosely coupled.
  • Documentation of behavior: TDD use cases can be used to document most of  the assumptions of a class.   It’s awesome that your test framework can document these assumptions in code and inform you of problems when the test suite is executed.
  • TDD encourages programmers to set and achieve goals:  By crafting a test case before writing production code, you are encouraging lots of good programming behaviors.    By writing a test first, your are more likely to be thoughtful regarding the naming of your methods.   You are more likely to be careful about the data getting passed into the method and how the method will return data.    TDD also encourages you to plan the behavior of the class.
In this post, we have introduced the basics of TDD and test first design.   The following video and e-book from Misko Hevery teaches you advanced concepts and tips for making your software more testable.    Misko is a thoughtful test professional from Google.    This is one of my favorite videos to help introduce TDD.  I hope you enjoy it.

InspiredToEducate.NET Posts

 

 

 

 
 Share on Facebook Share on Twitter Share on Reddit Share on LinkedIn
No Comments  comments 
formats

10+ Lessons To Help You Grow Your Skills as a Developer

Coding Dojo

The Google Developer Group of Mercer University strives to teach web and mobile developers about the various tools Google has available to help create great products more efficiently.  GDG Macon also helps technology students at Mercer University meet developers from the local community and provide community building for Middle Georgia IT professionals.

We have had a lot of fun building community and learning together in 2013 and 2014.  Just in case you missed all the action, we’ve collected many of the lessons from our sessions.   We hope the content serves you in growing your skills as a technology professional.

Fall 2013
Connecting Your Favorite Google Services Using Google App Script

Building Web Apps at Google Scale – Introduction To AppEngine

Finding Common Interests in Community Challenges and Hack-a-thons

Review of Tools for Android Development

Using “Coding Dojo” to Engage Learners and Have Fun

Ignite Talks on HTML5 – Lots of Learning in 5 minutes

Introduction HTML5 and JavaScript using Games

Spring 2014

Easy Data Visualization with Google Charts and JavaScript

Backbone.js

Introduction to Dart

Avast, Ye Pirates: Write a Web App using Dart

Coming Soon to Mercer GDG in Spring 2014


 
 Share on Facebook Share on Twitter Share on Reddit Share on LinkedIn
No Comments  comments 
formats

“STEAM: Creating A Maker Mindset” by @vvrotny and @speterson224

As parents and teachers, we encourage our kids to become well rounded people who love learning.   In our world of cell phones, ipads, and computers, it’s easy for kids to become passive consumers of media and technology.   We, however, want are kids to be active, curious, and creative.   Since I’m a musician and a software engineer, I hope that my kids learn to express themselves emotively and become creative thinkers.   We’re trying to foster a family culture where we are active, encourage tinkering, and building physical things with our hands.   

With these ideas in mind, I wanted to share a great video I found by Vinnie Vrotny and Sheryl Peterson entitled “STEAM: Creating A Maker Mindset.”   In this conference talk from the K12 Online Conference in 2013, they share their experiences encouraging a “maker” mindset in the Quest Academy .   Their school has a very unique class teaching design thinking to kids.    It’s giving me lots of ideas for building a maker environment for our family.    In this class, Sheryl encourages her students to invent a creative design problem and solve it.   With the tools and support of the teacher, the kids are encouraged to build their design.    In some cases, the kids ask Sheryl to assign a problem to them.    The kids aren’t used to having creative freedom to design and make.    In these cases, Sheryl encourages the students to keep thinking.   :)

Here are some of the key ideas that I enjoyed from the session.

How do you encourage the mindset of a maker?

  • What is a maker mindset?  Makers are people who have a persistent tinkering mentality.    While makers love to learn, they also enjoy transforming their new ideas into physical artifacts.    A makers mindset encourages continuous growth and a love of learning.
  • Values: In the design of their teaching style and environment, Sheryl celebrated the design values of Ideo, a prominent design and innovation firm.  
  • Model the “Maker” Spirit: The speakers noted that it was important to model the “maker” mindset for the students.   Instead of purchasing a professional “green screen” for the class space, Sheryl made one.   Sheryl took great care to construct their classroom environment and build many of their tools.  Students learn “DIY” by seeing their teacher do “DIY.”

Teaching style

  • Blending the best of many: The design class blends aspects from other class room experiences and environments:
    • Shop class
    • Art class
    • Computer lab
    • Project based learning
    • Science Lab
  • Environment is key: I see similarities between creating an effective educational maker space and the ideas from Montessori education .    While the students have freedom to decide on the goals of their design project and freedom to drive their activities, the environment is designed to foster student creativity and curiosity.   Like Montessori education, the intentional environment fosters learning and enables the students to personalize their learning.    The environment naturally encourages the students to collaborate too.
  • Maker spaces don’t need to start big and expensive.   The speakers shared that some maker spaces started $200.00 and very simple materials that you might find in an art classroom: tape, glue, cardboard, recycled equipment, etc.    Start simple and grow!

Resources and References:

It’s exciting to hear students say that the design class was their favorite class.   From pictures of their maker space, the students have tons of fun tools to explore: 3D printers, Scratch, electronics, art materials, etc.   This video is motivating me to clean up a corner of house to make it a mini-maker space for our kids.  Cool stuff!     


 
 Share on Facebook Share on Twitter Share on Reddit Share on LinkedIn
No Comments  comments 
formats

Using Ruby and Code Generation To Save Time

Speed

Working in information systems as a programmer, you often find yourself writing boring repetitious code over and over again. Think about it. Let’s imagine you are writing code to access the following table. How many times will you type those property names?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
CREATE TABLE user(
id VARCHAR(50) ,
user_name VARCHAR(50) ,
first_name VARCHAR(140) ,
last_name VARCHAR(140) ,
zip VARCHAR(20) ,
email VARCHAR(140) ,
enable_flag INT ,
password VARCHAR(140) ,
created_by VARCHAR(50) ,
updated_by VARCHAR(50) ,
created_at INT ,
updated_at INT ,
PRIMARY KEY ( id )
);

In typical business applications, you will repeat the column names of this table in a data transfer object, a repository class, unit test code, validation code and controller classes. It’s not the most exciting code, it, however, needs to get done. Inspired by talks by Kathleen Dollard, consultant and code generation promoter in the .NET community, I decided to build a small code generation tool for myself that would help save me time. I wanted to share parts of my code generation experiments with you. I hope the case study helps you in designing your own code generation strategy.

Building a Simple Code Generation Tool

To give myself a simple start, I decided to express my entities using XML Schema Definition(XSD), an open XML standard for describing the structure of information. XSD is pretty easy to code by hand. In the .NET world, it’s pretty simple to generate a XSD from your database using DataAdapters or other methods.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="user">
  <xs:complexType>
    <xs:sequence>
      <xs:element name="id" type="xs:string"/> 
      <xs:element name="user_name" type="xs:string"/>
      <xs:element name="first_name" type="xs:string"/>
      <xs:element name="last_name" type="xs:string"/>
      <xs:element name="zip" type="xs:string"/>
      <xs:element name="email" type="xs:string"/>
      <xs:element name="enable_flag" type="xs:int"/>
      <xs:element name="password" type="xs:string"/>
      <xs:element name="created_by" type="xs:string"/>
      <xs:element name="updated_by" type="xs:string"/>
      <xs:element name="created_at" type="xs:dateTime"/>
      <xs:element name="updated_at" type="xs:dateTime"/>     
      </xs:sequence>
  </xs:complexType>
</xs:element>

For this example, we will store the XSD in a file called “user.xsd.”

Using IronRuby, I created a class that would convert an entity expressed in XSD into code. IronRuby is an open source implementation of the Ruby language for the .NET framework. The IronRuby project enables programmers to blend the capabilities of the .NET framework and Ruby. When the “CodeGen” class is constructed, you provide a schema file, table name, a template, and namespace references.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/env ruby
load_assembly "System.Data"
include System::Data
require 'erb'

class CodeGen
  def camel_case(s)
    s.gsub(/(?<=_|^)(\w)/){$1.upcase}.gsub(/(?:_)(\w)/,'\1')
  end

  def initialize(schema_file, table_name, template_file, ui_namespace, model_namespace)
    if schema_file == NIL
      raise ArgumentError.new("schema_file is NIL")
    end

    if table_name == NIL
      raise ArgumentError.new("table_name is NIL")
    end

    if template_file == NIL
      raise ArgumentError.new("template_file is NIL")
    end
   
    if ui_namespace == NIL
        raise ArgumentError.new("ui_namespace is required.")
    end

    if model_namespace == NIL
        raise ArgumentError.new("model_namespace is required.")
    end
       
    if !File.exists?(schema_file)
      raise ArgumentError.new("Schema file does not exist: #{schema_file}" )
    end

    if !File.exists?(template_file)
      raise ArgumentError.new("template_file does not exist: #{template_file}" )
    end

    # read schema file....
    @data_set = System::Data::DataSet.new()
    @data_set.ReadXml(schema_file)
   
    #get table ref....
    @table = @data_set.Tables[table_name]
    @entity_name = @table.TableName.capitalize
    @table_name = @table.TableName
    @ui_namespace = ui_namespace
    @model_namespace = model_namespace
    @last_col = @table.Columns[@table.Columns.Count - 1].ColumnName
   
   
    #load ERB templates ....
    # http://stackoverflow.com/questions/980547/how-do-i-execute-ruby-template-files-erb-without-a-web-server-from-command-line    
    @template = ERB.new File.new(template_file).read, nil, ">"
       
    end
 
  def generate()
      return @template.result(binding)
  end
 
  def get_human_db_ref(strDbRef)
    strDbRef.capitalize.gsub("_"," ")
  end
   
end

I do acknowledge that we could have built this code generation framework using other technologies like T4, another template technology available for .NET. I, however, enjoyed getting to learn Ruby and ERB. Ruby is just a fun dynamic language! It’s nice that you can quickly edit the templates without compiling.

In the following lines, we create a “DataSet” object to read the schema data into memory. This enables the code generation templates to know the columns defined for the entity and their respective data types.

1
2
@data_set = System::Data::DataSet.new()
@data_set.ReadXml(schema_file)

Our templates that we will write depend upon several pieces of data: the schema data, entity name, table name, and other properties. We store these elements as properties on the “CodeGen” object. By doing this, the properties become available to the ERB template system.

1
2
3
4
@table = @data_set.Tables[table_name]
@entity_name = @table.TableName.capitalize
@table_name = @table.TableName
...

In the following line, we use a ERB template to convert the table data into code.

1
@template = ERB.new File.new(template_file).read, nil, ">"

The following code, shows a code template for generation an entity class in C#. The ERB template utilizes the standard ADO.NET methods available on a DataTable class.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
using System;

namespace <%=@model_namespace%>
{
    public class <%= @entity_name %>
    {

        <% for col in @table.Columns %>
        <%= col.DataType.to_s() %> <%= camel_case(col.ColumnName.to_s()) %>{get; set; }
        <% end %>      
       
        public <%= @entity_name %> ()
        {

        }
    }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
#!/usr/bin/env ruby
require 'CodeGen'
require 'fileutils'

def rscg(schema_file, table_name, template_file, output_file, ui_namespace, model_namespace)
  code_gen = CodeGen.new(schema_file, table_name, template_file, ui_namespace, model_namespace)
  output = code_gen.generate()
  aFile = File.new(output_file, "w")
  aFile.write(output)
  aFile.close
end

rscg("user.xsd", "user", "buildEntity.erb", "c:\\output\\#{table}.cs", "MyUINameSpace", "MyModelNameSpace")

RSCG stands for “real simple code generation.” To execute the code generation process on one entity, you need to provide the XSD file, a table name, a template file name, an output file, and name space references.

1
rscg("user.xsd", "user", "buildEntity.erb", "c:\\output\\#{table}.cs", "MyUINameSpace", "MyModelNameSpace")

In researching this blog post, I discovered many more potential code generation solutions. The listing include commercial offerings and open source options.

http://en.wikipedia.org/wiki/Comparison_of_code_generation_tools

On my weekend programming projects, this simple code generation idea has saved me lots of time. I’m currently adjusting my framework to generate unit test stubs, repository classes, entity classes, user interface, I hope you find the ideas helpful on your own projects.

Featured Posts on InspiredToEducate.NET

Photo from http://netdna.webdesignerdepot.com/uploads/2013/02/featured20@wdd2x.jpg

 
 Share on Facebook Share on Twitter Share on Reddit Share on LinkedIn
No Comments  comments 

No tweets to display

© Inspired To Educate
credit