While troubleshooting a flaky Windows server in our network, I came across an article on Technet named Top Ten Ways To Pump Up IIS Performance.
Aaron Lynch has posted some code examples for accessing the ColdFusion Admin Api. It is often a minor pain to have to go into the admin and turn on/off debugging on your development machine to test certain things. Additionally in our environment, in order to restart the ColdFusion Server service I have to remote into the server, open up services, and restart. Being able to open the CFEclipse Scribble Pad, and having quick and dirty access to these things has saved me time already this morning!
So here are a couple of snippets:
[note: in the examples, the password is set to "coldfusion". Alter that as you need to.]
- Restart the ColdFusion Server by typing restart[ctrl][shift][period] and saving/running. Here is the snippet:
adminObj = createObject(“component”,”cfide.adminapi.administrator”);
// Instantiate the serverInstance object.
myServer = createObject(“component”,”cfide.adminapi.serverInstance”);
- Turn On/Off debugging by typing debug[ctrl][shift][period]. You are then prompted for enable:true/false. Then save/run. Here is the snippet for that one:
adminObj = createObject(“component”,”cfide.adminapi.administrator”);
myDebugging = createObject(“component”,”cfide.adminapi.debugging”);
When you go out to his site check out his Flash Paper cheat sheets for all the API pieces. He put those together using the CFC documenting tool that I blogged about the other day.
I recently put a job posting out to my CFUG for an on-site Jr-Mid level ColdFusion developer in the DFW area and have had no luck at all. The only responses I have received are either from overqualified developers who were already engaged and just sniffing around, or people out of the area that wanted to work remotely. Many of the replies on the email list were from other people that had posted jobs previously and were making comments that they too were having a hard time filling spots. What a different time for ColdFusion developers today than it was a few short years ago!
But as nice as those implications are for us…. I need a developer now!
There is a something that I think many of us are guilty of from time to time. When you become proficient in a particular language or technology, it is very tempting to want to apply your tool of choice to solve whatever problem that comes along, even if a more objective perspective might show that there is a far more appropriate solution.
My Uncle John is in town visiting from New Hampshire, so I stopped at my parents’ house yesterday after work to chat with him for a bit. He and my father have at least 60 years of combined electrical engineering experience, and it is always interesting to me how many parallels there are between the problems and solutions in their industry when compared to the problems and solutions that I experience in software development. My uncle was talking about the problem of choosing the solution before you understand the problem, and how designer engineers often try to force their particular niche into circuitry design, whether it is the right solution or not. Obviously as a programmer I have seen the same behavior, and have certainly been guilty of it myself. He told me that when doing presentations, he has often told this story:
“So last night I was on my way out to the parking lot and I came across this guy under the big light out there. He was down on his hands and knees looking around. When I asked what he was doing, he told me that he had dropped his keys and was looking for them. Having a few extra minutes I figured I would help out so I asked him ‘OK, how big of a radius are we looking in here?’ while spreading my arms out in the area he was looking. The guy looked up kind of perplexed and said ‘No, the keys are over there…’ pointing across the lot ‘… but the light is much better over here’.”
It didn’t matter what the problem was. The guy had his solution whether it fit or not. I think it is healthy for us to remind ourselves not to fall in that trap.
Well, if you have ever spoken to me or read anything I have written, I hope you know that I don’t believe this. But here is the situation…
We have a developer in our company that dabbled in CF5, but now writes in .Net. She doesn’t follow any of the current articles/blogs/etc about ColdFusion and her coding style when it comes to ColdFusion is very procedurally oriented. The owner of our company has expressed interest in engaging her in some of our current projects. My manager wanted me to compile some pieces of information for her to read and study so that she can get up to speed in some of the current stuff happening in our world. Our newest applications are being written in Mach-II, so we wanted her to have an understanding of why we use them and the benefits they present. I gave her some email lists, fullasagoog.com, MXNA, mach-ii.info, and gave her a copy of Hal Helm’s presentation on Mach-II that he gave to the KCCFUG.
After spending some time reading she told my manager (loosely quoted)
“Frameworks seem to be complex, add difficulty, and don’t really offer benefits”.
While I was reeling from this response, I started spouting my usual rhetoric about standards, organization of code, like mindsets among teams, ease of maintenance, etc… However, I was realizing as I was talking that even *I* am tired of hearing myself talk about it, and I am sure my coworkers are as well. I think it might help if she heard come comments from other developers, and it might actually mean more. If you have a moment, I would love to collect some thoughts in the comments about how (or even why not) a development team can benefit by using a framework such as Mach-II, Model Glue, or Fusebox.
EDIT: I was unable to port my comments from my old blog into the current blog. However, I thought that I should go ahead and post them into this entry as there was a spirited discussion. Here they are:
Frameworks can be like toolboxes and they can also be sequences and styles of building houses. How do you lay the foundation, and then build the building on top. Yet, for different types of buildings you will find different frameworks and different building tools are better than others. The modern framworks are not for beginners and certainly (though not admittedly by the ‘devout’) not appropriate for every solution.
posted 1667 days ago
I have been working with Reactor for several months now and have grown fond of using iterators as collections of children objects. I never looked at the voodoo magic under the covers that makes that happen in the Reactor core files, but with a little playing around and testing today I realized it might not be so magic afterall. I created a CFC that accepted an array as an argument, then returned that array’s iterator() method. It is plainly obvious by looking at the code, but I just never knew you could do this. For anyone interested, here is the source of my test:
<cfreturn this />
<cffunction name=”returnIterator” returntype=”any”>
<cfargument name=”MyArray” type=”array” required=”true” />
<cfreturn arguments.MyArray.iterator() />
IteratorTest = CreateObject(“component”,”IteratorTest”).init();
MyArray = ArrayNew(1);
MyArray = “one”;
MyArray = “two”;
MyArray = “three”;
<cfdump var=#MyArray# />
<cfset MyIterator = IteratorTest.returnIterator(MyArray) />
<cfdump var=#MyIterator# />
<cfset thisItem = MyIterator.next() />
EDIT: useful comment from Mark Mandel on the matter:
I like this way of looping around arrays, but you can also do the same thing with Structs, but it just takes a little bit more work:
iterator = myStruct.values().iterator();
It should be noted that iterators for both Structs (Hashtables) and Arrays (Vectors) are ‘fail-fast’ – which means if someone removes and object from the array/struct not through that iterator, an exception will be thrown.
It may be worth making a top level copy of the array before returning the iterator to avoid collisions like these.
I am giving a presentation to my CFUG tonight demonstrating a method of writing your code in a way that will support multiple data persistence methods. In the example code, there is a mini-app that adds/edits/deletes addresses from the following storage methods: 1) MSSQL using Stored Procs, 2) MySQL using straight SQL, and 3) encrypted WDDX text files. The approach uses subclasses of the AddressDao and AddressGateway that are specific to the type of storage. Below is the blurb from the www.dfwcfug.com site:
Dave Shuck: Subclassing Data Components for Flexible Applications
One of the advantages that you hear repeatedly of a good OO design, using DAO and Gateway patterns is the database abstraction. One benefit of database abstraction is that your application is not tied to a specific database architecture. This means that if you suddenly need to uproot your site and move to a different database, you do not have countless queries buried throughout your code. If you followed the rules and followed the patterns, then you simply need to alter the code that persists your data in the DAO and Gateway objects. But what if you are building an application that you know will sit on several different databases or use different methods for data persistence? One method would be to create subclasses of your DAOs and Gateways that deal with specific persistence needs. I will be showing a simple example mini-application I wrote that will demonstrate how the database has a somewhat insignificant role in an OO system. We will be running the same code on top of three data persistence methods: 1) MS SQL with stored procedures, 2) MySQL with plain SQL, and 3) Encrypted WDDX text files (Why? Because we can!).
Project:Unity is a new feature in CFEclipse that allows you to browse an outline view of almost all ColdFusion framework XML files including MachII, Model Glue, Fusebox, ColdSpring, Transfer, Reactor (and maybe others that I missed!)
As you click down through the human-view and you select an element, it opens the config file and goes directly to that node. Even in the case of Fusebox with nested XML files (circuits) it actually opens the correct file and goes to the correct spot.
You can also right-click and add elements appropriately from the outline view. There are contectual drop-down menus that guide on adding new elements. This is SWEET!
This is also extremely configurable and makes for easy extensibility to add what you need or even create what you need for your own framework!
But…. what am I going to do with all these snippets?