August 2007


Development and School29 Aug 2007 03:02 pm

In CS 490T I am working on a team with two others creating a Rubix Cube project, one being Luke. We have have been struggling to find a nice, clean, object oriented way to represent the cube, but I believe that we have found a good solution. We are going to have a Cube class with methods that rotate sides of the cube. This class will have one property, a collection of Blocks. A single block has six properties: front, left, right, bottom, top, back. The way we will rotate the block will be by specifying a face (top, left, etc…) and a direction, clockwise or counter clockwise. Class outline is below.

Class Cube {
 Block blocks[20];
 rotate(Face, Direction);
}

Class Block {
 Color top;
 Color bottom;
 Color left;
 Color right;
 Color front;
 Color back;
}

The way that you can represent the position of the block is which faces are defined. If a color is not present in the block, then the color will not be defined. Such as the top middle piece will only have the top property not set to null. This way, you can know which position a block is in by knowing which sides have colors defined. So the position of the block with the top, left and front defined is the block in the upper left corner closest to you.

 ______
|\\_\\_\\_\\
|\\|X| | |
|\\| | | |
 \\|_|_|_|

I belive that this Rubix cube has many valid uses for LINQ. One such way defined below.

We were going to do a lot of nasty if statements like

if (top!=null) { //some block on top
 if (front !=null) { //some front block
  if (left !=null) { //top front left
  } else { //top front right
  }
  etc...
}

But instead, with LINQ, we can do the following:

SELECT * FROM blocks WHERE top!=NULL AND front!=NULL AND left!=NULL;

And that will do all the work for us.

I was thinking about other ways to use LINQ, such as the actual updates when a move is done.

UPDATE blocks SET top=(SELECT color FROM blocks WHERE...) WHERE ...

This will update all the block colors for a given move. This may or may not be simpler than a lot of if/else if’s with manual updating.

Development and Opinion15 Aug 2007 07:50 am

Often times, projects just need a cool cam

Development and Howto13 Aug 2007 08:50 am

I have just read about a new feature in Microsoft .Net 3.5 named LINQ. Microsoft describes this as

General-purpose query facilities added to the .NET Framework apply to all sources of information, not just relational or XML data. This facility is called .NET Language-Integrated Query (LINQ).

That, in my opinion, is a rather vague description of what this does. A query facility? Reading more, I see

We use the term language-integrated query to indicate that query is an integrated feature of the developer’s primary programming languages (for example, Visual C#, Visual Basic). Language-integrated query allows query expressions to benefit from the rich metadata, compile-time syntax checking, static typing and IntelliSense that was previously available only to imperative code. Language-integrated query also allows a single general purpose declarative query facility to be applied to all in-memory information, not just information from external sources.

This still doesn’t quite explain what this query facility with syntax checking and IntelliSense does. When I continued reading the page, I finally came across an example. Imagine the following C# code:

Using System;
using System.Linq;
using System.Collections.Generic;
class app {
static void Main() {
string[] names = { "Burke", "Connor", "Frank",
"Everett", "Albert", "George",
"Harris", "David" };
}
}

Now, imagine you wanted to get all the names that were 5 characters long, and print them in all upper case. What you would probably do is similar to the following: (PSEUDO CODE)

string upperNames[]
//get all names that are length 5 and push them onto the upperNames
for (int x=0;x if (names[x].length() == 5) {
upperNames.push(names[x].ToUpper());
Console.WriteLine(upperNames.peek());
}
}

Here is how you would accomplish the following with LINQ:

IEnumerable query = from s in names
where s.Length == 5
orderby s
select s.ToUpper();

Wow, that's some pretty cool stuff. There is some more stuff that is outlined in the article, but at a first glance, it's pretty neat.

Development and PHP13 Aug 2007 08:04 am

I recently read about how some of the source code behind Facebook was leaked. I read through some of it and as a PHP developer, it surprised me at some of the things that they have done.

Here is a small list of the features of their code:

  1. There is no object oriented code.
  2. There are a _lot_ of includes
  3. They use Smarty (or something built to feel like Smarty)
  4. They don’t use camelCase
  5. Many
    • Many
      • Many
        • Nested if’s
Opinion and PHP10 Aug 2007 03:18 pm

I recently read an article at ONLamp.com about why people write free documentation. As being part of the PHP documentation team, I thought that the article would be an interesting read.

The author goes to show that most people tend to write the documentation because they want a thriving community and personal growth, but they don’t write for thrills or because they enjoy writing. Let me reemphisize that last point: People do not write the documentation because they enjoy writing. I have often been asked why I started to join the PHP team, and I can honestly say that it’s not because I enjoy writing. My father often asks why I contribute to something where I get no monetary reward. It is hard for him to understand how this is like community service, but on a different level. I joined the PHP documentation team to help out and give back to the community, to learn PHP on a more intimate level, and to hopefully be able to study the source and contribute to PHP 6 and beyond.

I enjoy working with the PHP team and have been slacking off in my contributions, but I hope to find some time to help out during the school year.

Development07 Aug 2007 06:37 pm

I have been working on the MyEPICS framework for a few things here and there, and we have this Role Based Access Control (RBAC) system in place. Now, one thing that has caught my attention is the need to find _every_ action that a user is able to perform, and what object he can perform them on. The query is pretty gnarly:

SELECT Object.name, Action.name FROM UserRole
INNER JOIN DomainPrivilege ON DomainPrivilege.roleid=UserRole.roleid
INNER JOIN Role ON UserRole.roleid=Role.id
INNER JOIN Domain ON DomainPrivilege.domainid=Domain.id
INNER JOIN DomainObject ON Domain.id=DomainObject.domainid
INNER JOIN Object ON DomainObject.objectid=Object.id
INNER JOIN Privilege ON DomainPrivilege.privilegeid=Privilege.id
INNER JOIN PrivilegeAction ON Privilege.id=PrivilegeAction.privilegeid
INNER JOIN Action ON PrivilegeAction.actionid=Action.id
WHERE userid=?

Is there some other way to accomplish the same task, or do I just have to join 9 different tables to get this information, and what are the performance risks for doing this?

Development and Howto and Whirlpool02 Aug 2007 03:37 pm

Please note, these are all my own personal views and are not in any way representative of the company I work for.

At Whirlpool, I have been working with two form building utilities for SAP. I was looking at these solutions for creating an offline expense reporting tool for SAP’s Travel Management module. One of them is Adobe Interactive Forms and the other is Microsoft Infopath. Both of these are extremely powerful tools that allow you to quickly create forms. What’s even better, is that given a web service, both of them can create a form that molds to it in a matter of a few clicks.

The Scenario

A tool is needed to be developed to allow for an employee to create an expense report while traveling on the plane. Like e-mail, this tool should be able to synchronize all data when it is first launched. When offline, the traveler should be able to fill out the expense report as if at the office, connected to the network. When the traveler comes back online, the report would synchronize again and submit the data that has been changed. We believed that the best solution for our scenario was to create web services that would allow us to accomplish all of the synchronizing calls to the back end system.

Adobe Interactive Forms

Adobe Interactive Forms seemed to be the most widely used method by companies that use SAP. When looking online and through documentation, creating them to use web services didn’t seem to be used at all. I investigated and poked and prodded until I was able to find that you can access Adobe LIveCycle Designer directly from: “C:\Program Files\Adobe\Designer 7.1\FormDesigner.exe” without having to go through SAP NetWeaver. From here I was able to bind it to a WSDL file, but for some reason it would never submit the data, or receive anything back. Clicking a button did nothing. It was like an HTML input button w/o a form surrounding it. After a few attempts to get it to work, I noticed that if I click on the button, go over to the “Execute” tab, then tell it to post to server, and not the client, then it appears to do something.
change.PNG

Then I went and tried to submit the form and this is the result that I got
error.PNG

I was never able to find a solution to this error, as descriptive as it is.

Microsoft Infopath

Using Microsoft Infopath, File->Design a form
1.PNG

You want to send and receive data from this web service
2.PNG

Then manually type in the address to your WSDL file.
3.PNG

Click next a few times until you get to this screen, and choose to send the entire XML file.
4.PNG

Now, expand all your fields and drag the queryFilter folder into the top box, and choose the relevant selection. I was using BAPI_GET_USER_DETAILS
5.PNG

Do the same with the lower field.
6.PNG

Preview the form and you should have a fancy web service running with Microsoft Infopath.

Near the time we were going to get into the thick of the tools, we had the web services take a dump on us. I was investigating how we were going to create web services for our travel expense solution when our project stopped. It was a shame as it was interesting to see how such powerful functionality can be built in a relatively short amount of time.