On twitter... and feeling slightly dirty about it

Wednesday, June 25, 2008

Peep dis: within the past year, we hired this young kid named Mike. I call him Facebook (because he's young, natch) and he calls me Gramps. It's great. Anyway, i bust his balls because he's on this twitter thing, and he "tweets", and i'll be damned if that's not the fairiest sounding word ever verbed. Every time I type it I want to kick my own ass. So I'm at cfunited and I'm wondering, "is that little bastard doing any work today while I'm gone?" I sign up for twitter and try to follow him, seeing if he's tweeting away every 5 minutes instead of doing whatever it is he does at work. Well, he wasn't tweeting, so I assume he was on youtube or some other time drain. Anyway, here's what I'm wondering, now that I'm on this thing: what's the value? What will it bring my life that I don't already have? In what ways are people using it that helps you out day to day? I'm not asking as a smartass. I'm asking because I really want to know. i'm at twitter.com/marcesher I don't know why yet. Maybe after every 10 tweets (dammit!) they'll send me a free dunkin donuts gift card or something.

CFUnited: Automating the Build & Deploy Process with ANT

Tuesday, June 24, 2008

I was presenting on an old ghetto laptop that couldn't run connect (although in all fairness to the P.O.S. machine, connect is a total hog.). Anyway, the most important part other than my charm and grace is the code, right? So the presentation, with all promised code, jar file dependencies, etc is here at the bottom of the page. My "wingman", the goatee'd fellow asking really good questions, asked me another great one the following day and I thought it bore mentioning here. During the 2nd part of the presentation, I demo'd macrodef and used an example of looping over a query of servers, and for each server, running a bat file that would open up a connection to that server. Then, it'd copy the code. Then, it'd run that same bat file and close the connection to the server. Currently, our environment is completely locked out of the prod environment, rightfully so. And so in my example, I was saying that the bat file in question would temporariliy open up a connection to each production server and then close that connection. My goatee'd wingman asked, "but that doesn't prevent you from running that bat file any other time, does it?" And he's absolutely right. Here's a case where I'm hoping that our network admins will work with us, understanding that we have nothing to gain by opening up those connections except during the deploy process. But that remains to be seen. This is definitely a case of "let's compromise". So, thanks to all who showed up for the session, and extra special thanks for the brave folks who stuck around for the 2nd half of it! For the curious and bored, here's the code in question. The contents of OpenOrClose.bat are irrelevant here... it's the concept we were discussing that matters. The "deployToAllServers" target is the big daddy.
<project name="CFUnited (j): SQL, for, MacroDef, and exec" basedir="." default="getServers">

 <target name="init">

     <property name="app.name" value="Client1App" />

     <property name="dev.root" location="DEVSERVER" />
     <property name="test.root" location="TESTSERVER" />
     <property name="locations.dev.clientroot" location="${dev.root}\${app.name}" />
     <property name="locations.test.clientroot" location="${test.root}\${app.name}" />

     <property name="locations.dev.customtags" location="${dev.root}\CustomTags" />
     <property name="locations.test.customtags" location="${test.root}\CustomTags" />

     <property name="locations.test.deploy" location="${locations.test.clientroot}\deploy" />
     <property name="locations.test.deployzip" location="${locations.test.deploy}\${app.name}.zip" />

     <!-- read all our 'secure' properties from this file; this defines the sql.userid and sql.password properties -->
     <property file="unames.properties" />

     <!-- create a classpath for ANT to use for finding and running the jdbc driver(s) -->
     <property name="jdbclibdir" location="lib" />
     <path id="jdbc.classpath">
         <fileset dir="${jdbclibdir}">
             <include name="**/*.jar" />

     <!-- these properties would be better placed in a .properties file -->
     <!-- this will use the jtds.jar in the classpath -->
     <property name="sqlserver.driver" value="net.sourceforge.jtds.jdbc.Driver" />
     <property name="sqlserver.url" value="jdbc:jtds:sqlserver://localhost:1436/ANT;instance=NetSDK" />

     <!-- this will use the mysql-connector jar in the classpath -->
     <property name="mysql.driver" value="com.mysql.jdbc.Driver" />
     <property name="mysql.url" value="jdbc:mysql://localhost/ANT" />

     <!-- this is where the sql resultset will be stored -->
     <property name="db.output" value="serverslist.txt" />

     <!-- http://sourceforge.net/projects/ant-contrib -->
     <taskdef resource="net/sf/antcontrib/antlib.xml" classpathref="jdbc.classpath" />


 <target name="getServers" depends="init" description="Queries a db for a list of servers">

     <sql driver="${mysql.driver}" url="${mysql.url}" userid="${sql.username}" password="${sql.password}" classpathref="jdbc.classpath" print="yes" output="${db.output}" showheaders="false" showtrailers="false">
     select ServerIP from servers where ActiveFlag=1



 IMAGINE: You have a database table of servers to which you'll deploy.
 You want to query for the "active" servers, and for each server
 Copy your code onto it. This would assume an active network connection between
 the machine you're on and the servers to which you are deploying

 <target name="loopOverServers" depends="init,getServers">
     <loadfile srcFile="${db.output}" property="serverlist" />
     <for list="${serverlist}" param="server" delimiter="${line.separator}">

             <echo>Copying to @{server}\Apps\${app.name}</echo>

             <copy toDir="@{server}\Apps\${app.name}" preserveLastModified="true" includeEmptyDirs="false">
                 <fileset dir="${locations.test.clientroot}" />

                 <format pattern="MM/dd/yyyy hh:mm aa" offset="-5" unit="year" property="customtagfilter" />
             <copy toDir="@{server}\CustomTags" preserveLastModified="true" includeEmptyDirs="false">
                 <fileset dir="${locations.test.customtags}">
                     <date datetime="${customtagfilter}" when="after" />



 You want to do the same as above, but you need to open and close the connection to each server
 because your network people run a tight ship, and they don't want connections open
 between your dev environment and your other environments except
 during the brief time it takes to copy code


 <target name="deployToAllServers" depends="init,getServers">
     <!-- open the connections using a bat file provided to you by your network admins;
     we'll call the bat file using a self-made task that we create with macrodef -->
     <OpenOrCloseConnections action="open" />

     <!-- call the loopOverServers target and copy all code -->
     <antcall target="loopOverServers" />

     <!-- close the connections -->
     <OpenOrCloseConnections action="close" />

 <!-- MACRODEF: this little gem lits you define your own tasks! -->

 <macrodef name="OpenOrCloseConnections">
     <attribute name="action" default="close" />
     <!-- imagine: this OpenOrClose.bat is provided to you by your network people to open
     up the appropriate connections, and then close them, for the life of your script.
     In this way, you can directly copy files across the network during a brief window of
     access and then automatically remove that access once the deployment is over -->
         <exec executable="cmd">
             <arg value="/c" />
             <arg value="OpenOrClose.bat" />
             <arg value="-@{action}" />


 Imagine a table called "Deployments" and a table called "J_Deployments_Servers". And
 every time you deploy, you insert a row into the deployments table, get the ID
 of that deployment, and for each server you copy code to, you insert a row
 into J_Deployments_Servers with some audit information (IP address of machine
 from which the deployment was run, the exact time of the copy, etc).

 How would you do that using sql and macrodef up in your loopOverServers target?



CFUnited Wrapup #341

Monday, June 23, 2008

All the young hipsters have been busily writing up their cfunited wrapups, so I'm jumping into the fray mostly because it will force me to review all I learned. I want to get one or two sentences about each session to force concision. There's nothing like writing about something to help you crystallize your thoughts. Ideally I'll get out of the blather I'm about to spew at least a 3-minute sales pitch for why my company should consider sending people next year or why people I work with should consider going even if the company doesn't buck up. This whole business of "who should go to conferences?" is a topic i have a lot of thoughts on, but it is a post for another time. Like you care, I know. So, here goes: keynotes: I'm not gonna dis michael smith's keynote b/c i want to present at cfunited next year. As for ben/adam's adobe keynote, the "announcements" have been covered ad nauseum by all the other cool kids. I have two additional thoughts: #1) those of you dying for hibernate.... have you ever worked with it? do you know what the implications are? I've built some fairly sizable java apps in spring and hibernate, and I tell you this: it's no magic bullet. More on that for another post maybe. And #2) talk about nail-in-the-coffin for CFEclipse. Up until now the teasing has been mild. Annoying, but mild. Now it's bordering on hand-down-your-pants. I asked adam haskell if he'd consider contributing to cfeclipse. He summed it up thusly: "Did you hear today's keynote?" Nuff said. Project Explorer --> org.cfeclipse.cfml --> right click --> close project. I hope I'm wrong, but I doubt it. Session #1: Jeremy Kadlec, Advanced Search with SQL Server Bottom line: It's easy! I had no idea how powerful full text searching was in sql server. Must consider, though, the performance implications of inserts/updates when the text index is set to auto-build, similar to the considerations of loading up tables with indexes. For me, this will come down to load testing. ain't no way to guess through this one... just gotta do it and see what happens. Also, must remember to add mssqltips.com to the ol' feed reader. Session #2: Bill Shelton, Patterns for test automation As Bill said, "that's a pretty grown up title!". So was the session description. Still, it was obvious that much of the audience needed an Intro to Unit Testing presentation first. This is fine, but it slowed bill down b/c he had to answer a lot of questions ("what's an assertion?"). But he did manage to have at least enough time for to get across probably the two nuggets of gold he was going for: #1) dependency injection is critical for getting the most out of unit testing. #2) how to use cfeasymock. It's is so much clearer to me now having seen him use it. I don't know why, but the docs for cfeasymock just confuse me. Bill's example -- probably because he thoroughly explained exactly the kinds of dependencies he was trying to get around -- was crystal clear. Maybe it's because i was sitting in the front row, but his example nailed it for me. Bill works on ubuntu so couldn't give the preso over connect, but I do hope he can find the time to do the recording soon. Session #3: Hal Helms, Object Oriented best practices Hal seemed sick. But his message -- question the pseudo-OO that some folk preach -- came across nicely. I love Hal's "question everything" approach. He makes you a better programmer just by reinforcing the idea that it's OK not to believe everything you read, that you gotta think for yourself and earn your answers. Practical example: "bean" objects that are just bags of getters and setters, with no behavior and just data, aren't very useful for us CFers and are more pain, less gain. This is in line with Hal's general "don't start with the data(base)" philosophy. Anemic domain = bad. Objects that do stuff = good. I'm going to give hal's 6-line-maximum method approach a shot and see how it changes the way I think about code. Session #4: Nic Tunney was supposed to talk on section 508 and RIA, and I was going to go to that. But he didn't show, so I called it a day. Session #5: Adam Haskell, Code Reviews and Mentoring BOF (birds of a feather) You know what: I have too many thoughts on this one. I want to let it gestate and write about it down the road. Interestingly (to me and only me), this BOF was probably the session whose content is nearest to my heart. So I want to say more at a later time. MAD props to Adam for leading this extremely important and eye-opening session. But tell me: why can't conference organizers have the event staff put the rooms into a circle or square for the BOFs? c'mon, people. pay the extra 100 bucks and get the rooms properly configured. Thursday, Session #1: Clark Valberg and Hal Helms, Prototyping for Smarties. Here's an example of how chance encounters change the course of things. On Wednesday, I was standing in the lunch line with no one to talk to, and behind me was this girl and two dudes. Girl is on the phone. She hands it to dude #1. Within 10 seconds I'm thinking to myself "this is possibly the funniest conversation I've ever heard". Girl was Anne Nelson (Hi Anne!). Dude was Clark Valberg, who called himself the sometimes "office minstrel". Damn is he funny. Anyway, next morning I'm reviewing the schedule and I saw he was talking with Hal, and although I hadn't originally planned to attend this session, I figured that i just had to see it. Something about meeting him in the lunch line. Anyhoo.... This session was useful for me but would've been about 10 times more useful for the project management department where I work. I'm going to try really hard to get a few PMs to watch the connect preso with me. It was excellent. Hal's story about Joe the Warehouse guy really drove home the notion of the near-impossibility of nailing down specs, and coding to them, when the specs are driven by a select few and not the people using the software. Classic case of "this is what we thought we needed but it's not what we needed". We fight this where I work all the time and so it's a topic that's becoming really hot. This one hit home. Now, I know that the one person out there reading this is gonna be like "duh, go agile". To which I reply, try turning around a battleship just because it's going to hit the little tiny fishies in its way. Change is slow in big companies. Change is slower when leaders aren't strong. Change is excrutiatingly, unbearably slow when leaders simply cannot lead. Read into that what you will. Session #2: Mark Drew, Fresh Air with Aptana I've seen 3 or 4 presentations on AIR. Maybe b/c of seeing them, or maybe b/c mark drew was so great, this one was the best of the lot. Not the concept of AIR, but the "how to get started cranking out apps". I think seeing him go from scratch, through creating a fairly realistic app, is what made this one so good. For me, there's nothing like a "start at the start" kind of presentation to make an abstract thing more concrete. As a speaker, here's what you want: you want the audience to think "yeah, I could go home and get started with this right away", and that's what I felt after this session. When you present, you're not just competing for the hour during which your session is held, but for the limited free time that your attendees can commit to new things when they get back to work. Host My Site Keynote: I sat in the lounge room shooting the breeze with some of my new favorite people, Adam Haskell and the kroger crew (9-v Lauren, Tony, Bob, Steve, Dustin, and Chad). Hostmysite could've given away free beer and I'd still have had a better time doing exactly what i was doing. Without doubt the best thing about conferences, if you're not afraid of people, is meeting new people. I spent a lot of time with the wonderful gal and guys from kroger over the 3 days and am very thankful for that. If I have a regret it's that I didn't get to throw down those massive hotel beers with em. Maybe next time. Session #3: End to end performance tuning. Honestly, it felt really rushed. I actually don't remember much useful stuff from the first part, but maybe that's because I was tired. I'm going to download the slides and review it again, though. One cool thing was hearing Nate Nelson talk about the stuff I'm absolutely clueless about, i.e. hardware. My 2-sentence summary: use trusted cache, index your databases, and the type of raid you choose will be a trade-off between redundancy and performance (unless you like blowing wads on raid-10). Exactly one week ago when hearing "raid 10" I would've responded like a drooling idiot. Thanks for showing me the light Nate. Session #4: Patrick Quinn, Server Down and how to react. I had to leave about 15 minutes early to prepare for my presentation, so I missed the good stuff at the end. I really liked his notion of "crash patterns" though. This is one I'll be reviewing down the road as I try to ramp up with more load testing. One thing I'm still waiting for though is some smarty to finally tell me "here's how to find what's holding your memory". I haven't had this satisfactorily answered yet. Probably because it's not so cut and dry. But please, someone smart, can you please tell me how to figure this out? In 5 minutes? Otherwise, I'm going to have to get all Java Profiler on your ass, and you don't want that. When I open up YourKit and point it at CF, puppies die and angels lose their wings. For the good of the little children, please, answer this question. Session #5: Me, Automating stuff with ANT I had a wonderful time. But damn I wanted to see Adam Howitt's presentation on amazon ec2, which was going on at the same time. Oh well... the things you suffer for your craft. Friday, Session #1: Dan Wilson, Refactoring procedural to OO OK, I'm biased here. Within 10 minutes of meeting Dan Wilson at the speaker dinner on Tuesday, he offered me a beer (note to teratech: please, buck up for some drinks next time). The rest was history and if I lived in bumf**k north carolina, where dan lives, i think we'd be fast friends. that's a joke dan will get because I live in bumf**K pennsylvania, aka "pennsyltucky", so the degree of bumf**kness is debatable and kind of funny, in a "more people have been arrested for having sex with sheep in my state than yours, buddy" kind of way. Also, Dan was incredibly gracious by engaging my wife in conversation while i geeked out with mike brunt at the crime museum talking clustering beside the corpse. If it weren't for dan, I don't know who'd have been more bored, the dead guy or my wife. Anyway, dan's a very articulate speaker and had great examples. The contrast of the original kalendar app, in all its nasty spaghetti glory, with the newer OO version, was stark and told the story better than an hour lecture could have. I think I may ask dan for permission to use this presentation as the basis for some teaching/learning where I work. Or i might just steal it. Session #2: Michael Collins, deploying into large scale environments. This one, I think, was just not what I was looking for. I was hoping for more practical examples of how to move all your code from a central place into 1000 servers during a production deployment. I didn't get that. That's not Michael's fault, just a difference in expectations. If you don't know what car files are, this was a good talk. One thing he did support, though, was keeping code on a SAN, which we're fighting for at work. So having someone from adobe say "yes, this is a good thing" will go far for me. He did talk about creating sort of a "reference" ear file that you could deploy. Now, I might just be a complete mouth-drooling douchebag, but if i have a farm of dozens/hundreds/thousands of servers, is moving a 200MB ear file across the network to all those servers realistic? i didn't think so either. maybe that's why he pushed shared/network code so much. Session #3, Luis Majano, Intro to Coldbox Mine eyes have seen the glory, and it is coldbox! Holy freakin' crap. Tell you this, if you're going to do event-driven programming, you gotsta have an execution monitor. This framework feels like it was built by 10 people who want nothing more than to help you do your job kickass, day in, day out. I spoke with 5 or 6 different people right after the presentation, and the reaction was eerily the same: "this is the first framework that actually excites me and makes me want to use it". This will sound teh ghey, but during the presentation I was thinking of kathy sierra's mantra of "helping your users kick ass". Coldbox isn't "look how smart Luis is" (very). It's "look how good you can be". Very soon I'm going to have a (rare) opportunity to do a greenfield app at work, and I'll be putting coldbox to the test with it. This is the same feeling I had about Spring about 2 years ago, and I've not regretted that decision one bit. Session #4: Mike Brunt, High-availability CF Clustering Bottom line, load test. I really liked mike's no-nonsense demo of watching a cluster work under load. He brought servers down, put them back online, and we saw the results. Also, mad props to kurt wiersma who, as an audience member, gave the 30-second explanation of how to do URL recording in JMeter (my load test app of choice). I never knew that!!! thanks Kurt. Although that app mike was using was pretty darn sweet. Session #5: Elliot Sprehn, Internals of CF Um, uh. I'm no community fanboy, eagerly reading blogs all hours of the night, keeping my finger on every pulse and generally being "with it". But I read my fair share. Where the hell did this dude come from? A few weeks ago I see his name on Ben Nadel's blog, he's talking good smack, and I'm like "I gotta see this dude's talk at cfunited". So i switched to it on my schedule, and holy bejesus is this dude good. Outstanding talk. Note to the youngins in the crowd: you gotta work reeeeeeeeaaaaaaallll hard to get as good as elliot. I will not do his talk a disservice by attempting to sum up any of it. It's best seen from the source. But i will say that his point about "hey, people, this undocumented stuff ain't gonna change" is one I'm more than willing to listen to. But seriously, if you only have one hour to live, and you're not doing anything else, go watch this connect presentation. Fascinating. Saturday, Session #1: Sean Corfield, Event Driven programming This was the only session I could catch on Saturday. I think some people might have seen it as an advertisement for edmund. I didn't. I thought he did a fine job of describing event-driven programming in the context of a real framework that supports it. I'm going to try to give more thought later to why exactly this presentation made sense to me, because by rights it should've confused the hell out of me, but it didn't. I think probably it's having spent so much time programming eclipse. Although I honestly believe if I get one thing out of this presentation it's a fresh perspective on eclipse plugin programming. Go figure. I'm still dubious about debugging event-driven apps, though, without a proper mechanism for doing precisely that, especially asynch events. This is why the coldbox execution monitor is so appealing, by the way. I've done "debugging through logging", and it's about as enjoyable as a pick-axe to the sphincter. Here's high praise, not that it means much coming from me but what the hell: on the way home after the talk, my wife asked me the wifey-est of wife questions: "are you ok? what's wrong?" nothing! I was just in real deep thought, driving slow up 295 thinking of sean's talk. Sunday, 6:30 - 8:30 PM: Monster 8-inch Gurkha shaggy cigar and glass of balvenie 12-year to celebrate the excellent week I had. This week: back to the daily grind, but reinvigorated and full of ideas. Thanks to all the presenters and great people I met. Truly a pleasure! My Regrets
  • Not meeting chris scott. I've read enough by and about chris scott to know he's the real deal. He seems like a "wild brain", a higher mind, and I wish I had the chance to talk to him and see how his mind works. I hope I get to do that some time.
  • Not having a better laptop for my presentation. See, I usually borrow a machine from work b/c they're badass, but they were all in use this week. So I had to use my wife's work laptop, which barely runs eclipse. Connect kills it dead, so I couldn't record my presentation while it was happening, and I can tell you it's far better live than when I deliver it without an audience.
  • Not taking pictures. What was I thinking? I wish I had a picture flexing with Ben Nadel. O'course, his arms are bigger than my head, but still, it'd have been cool.
  • Spending 10 bucks for a bottle of delirium tremens. Stoudts abbey triple, while not as refined and "complex" and sophisticated, is definitely just as enjoyable to my uncivilized pallate and at 36/case is far less expensive
Next Steps
  • Download all the slides from the presentations I went to and review them again in a week.
  • Reinstall that plugin-virus Aptana and start using the code samples.
  • Set up a load test for our flagship app. Nothing fancy, something simple. Just get started.
  • We bought seefusion a long time ago... get it set up on our production servers and not just development.
  • Have a talk with my bosses about getting more people involved next year.
  • Talk with my mentee at work about him presenting next year.
  • Pour a 40 on the curb for my dead homey cfeclipse
  • Find one large method in one component and break it down into methods of 6-lines. Decide: what'd I gain?
  • Find one component that's not tested because of dependency difficulty and put cfeasymock to work on it. Decide: what'd I gain?
  • Schedule a meeting with PM to watch Clark and Hal's presentation.
  • Check out mssqltips.com
  • Start thinking of a topic to present next year. I'm thinking "Java Profiling your CF Server".
Again, thanks to everyone I met, everyone who presented, and the fine folks at teratech for putting on the show! Marc

My CFUnited Schedule

Friday, June 13, 2008

This is the first time I've been to cfunited since 2002, when it was CFUN. I really wanted to go this year, and since I wasn't in time to get it on my company's budget for this year, I figured the only way I was going was if I were a speaker. So I'm giving an ANT presentation Thursday at 4. I'll be covering all the basics of packaging apps and deploying them, but also getting into neat stuff like using antlib for looping, scriptdef for string parsing, sql, etc. I'm really excited about presenting this topic, primarily because I see how much time ANT has saved us over the past year or so. I hope to channel the spirits of my cf ant heroes (Luis Majano, Mike Henke, Jim Priest) and give a kickass presentation. Plus, since it's the last presentation of the day, I'm free to stick around and talk more ant after the session (at the bar, with beers. beers and stogies, even better). OK, so enough advertisements. Here's what I'm going to this year. I'm going to try to stick around Saturday and attend some sessions, too, but I didn't sign up for any since I'm not sure yet.

Wednesday, June 18, 2008

Start End Speaker Session Track
8:30AM 9:00AM Michael Smith TeraTech Keynote KEY
9:00AM 10:30AM Ben Forta Adobe Keynote Presentation KEY
11:00AM 12:00PM Jeremy Kadlec Building Advanced Search Capabilities for your web site with SQL Server DDT
12:00PM 1:30PM Lunch
1:30PM 2:30PM Bill Shelton Patterns for ColdFusion Test Automation DDT
2:45PM 3:45PM Hal Helms Object Oriented Best Practices ADV
4:00PM 5:00PM Phill Nacelli Leveraging Basic Object Oriented Concepts in ColdFusion GCF
6:30PM 8:30PM Networking Event
8:30PM 9:30PM Mark Drew Improving Quality through Code Reviews and Mentoring BOF

Thursday, June 19, 2008

Start End Speaker Session Track
8:15AM 9:15AM Kurt Wiersma Leveraging Popular ColdFusion Frameworks To Make Better Applications FWC
9:30AM 10:30AM Mark Drew Fresh AIR: Getting to grips with Aptana and AIR apps RIA
10:45AM 12:00PM Lou Honick HostMySite Keynote Presentation KEY
12:00PM 1:30PM Lunch
1:30PM 2:30PM Matthew Woodward Real World Flex and ColdFusion RIA
2:45PM 3:45PM Patrick Quinn Server Down - How To Prevent It, And How To React To It DDT
4:00PM 5:00PM Marc Esher Automating the build/deployment process with ANT DDT
7:00PM 9:30PM ColdFusion Celebration

Friday, June 20, 2008

Start End Speaker Session Track
8:30AM 9:30AM Dan Wilson Refactoring to Object Oriented Programming in ColdFusion ADV
9:45AM 10:45AM Mike Nimer Flex 3 For ColdFusion Developers RIA
11:00AM 12:00PM Multiple Speakers Demo Durby KEY
12:00PM 1:30PM Lunch
1:30PM 2:30PM Luis Majano ColdBox Framework 101 FWC
2:45PM 3:45PM Mike Brunt High Availability - Clustering ColdFusion DDT
4:00PM 5:00PM Elliott Sprehn Internals of the Adobe ColdFusion Server ADV
4:00PM 6:00PM
See you there!

GIT with it

Wednesday, June 4, 2008

Unlike Linus Torvalds, I won't call you stupid and ugly if you use CVS or Subversion. If you use VSS, you already know you are stupid and ugly - from 9-5/M-F I am very stupid and ugly for just this reason. And, the thought of being able to have a distributed network of trust and knowledge such that we can pull intellectual assets (source code and binaries) directly from each other as opposed to a single repository is a fascinating concept and challenges me to think differently. It becomes more of a graph model for collaboration, or a web, rather than some more linear constraint where we are dealing with a single definitive reference for software resources. This is not so say the there doesn't need be some kind of centralization at times, but when a team is geographically dispersed, sometimes on-line, sometimes off, being able to build software and collaborate efficiently just makes sense. Git claims and delivers performance. It is fast. It's merging capabilities are supposed to be strong; and that's next on my list, as that, for me, can be the most painful part of source code management. The security built into git is also very good, from what this inexperienced hack can tell. I'm brand new to git but have set up a source tree for MXUnit at GitHub. I hope to keep it in sych with the existing main Subversion repository. Note that MXUnit has no plans yet to move to git, we're checking it out. Git – Fast Version Control System http://git.or.cz/ Git on MySys (Windows fork) http://code.google.com/p/msysgit/ Google Tech Talk: Linus Torvalds on git http://www.youtube.com/watch?v=4XpnKHJAok8 MXUnit pulic Git repository http://github.com/virtix/mxunit/tree/master I'd be interested to hear about your experience with git ... thanks, bill

How I set up CFEasyMock

Tuesday, June 3, 2008

CFEasyMock is the latest mock framework for CF. It's based on the popular EasyMock framework for Java and is quite a nice port from what I can tell. If you set it up exactly as the author has packaged it, and if you already have cfcunit installed, then you should have no problems getting started. If you're like me and aren't keen on the way it's distributed, and if you want to change CFEasymock's own unit tests to use MXUnit, here's what to do Changing directory structure I don't like how it has 4 separate directories for a single framework. It's built like so:
  • easymock
  • reflect
  • samples
  • test
Why are samples and test outside of easymock? I don't know. Why is reflect outside of easymock? because it's technically a separate project. OK, fair enough. I'll live with that (for now). So here's what I did:
  1. Download latest cfeasymock
  2. copied reflect into my webroot
  3. copied easymock into my webroot
  4. copied test and sample into that easymock directory
  5. copied easymock word doc into easymock directory
  6. copied reflect word doc into reflect directory
  7. created a new eclipse project for the easymock directory
Setting it up to use MXUnit
  1. In Eclipse, selected the "sample" and "test" directory
  2. Hit CTRL-H to pop up the search box
  3. enter org.cfcunit.framework.TestCase into the "Containing Text" box.
  4. Filter on *.cfc
  5. Select "Selected Resources" radio button if it's not already selected
  6. Click Replace button
  7. Enter mxunit.framework.TestCase into the "With" box.
  8. Click "Replace All"
Running the tests in MXUnit As of now, all but two of the tests should go OK. The two that won't are in ResultTest.cfc because they use an assertion from CFCUnit that MXUnit doesn't copy verbatim, the "AssertClass" assertion. MXUnit has an AssertIsTypeOf(), though, so we'll just swap the two. In testCreateReturnResult, change the cfset assertClass.... to this: <cfset assertIsTypeOf(returnResult, "easymock.Result", "value returned from createThrowResult() is not of type easymock.Result" ) /> In testCreateThrowResult, change the cfset assertClass to this: <cfset assertIsTypeOf(throwResult, "easymock.Result", "value returned from createThrowResult() is not of type easymock.Result" ) /> Now, all tests should pass when you run them in MXUnit. Running the "Samples" In the Samples directory there are two test cases: TestClassUnderTest and TestUser. If you run them in the directory structure we've just created, they'll fail with a "Could not find the ColdFusion Component or Interface "sample.User".... and so on. So we just need to prefix the "sample" with "easymock." to get the right component path.
  1. In Eclipse, highlight the "sample" directory
  2. Hit CTRL-H, do a replace-all of "sample." with "easymock.sample."
That'll get "TestUser" to run OK. From there, I tried running the TestClassUnderTest tests, but I got errors about "Could not convert the value of type class coldfusion.runtime.TemplateProxy to a boolean. And for now, I don't have the time to debug it. If I get some time I'll post back here. With that bit of cleanup out of the way, I'm ready to start easymocking. I look forward to having this tool in the toolbelt. As I get time, I hope to add more posts on using easymock in the real world. --marc