Archive

Archive for the ‘Technologies’ Category

The Tools of Open Source

October 27th, 2009

As some readers will know, I’ve been working to study the architecture of FireFox. One thing I realize is that I’m not as familiar as I should be with some of the common open source tools, or what I consider to be the common open source tools.

Below is a list of tools that are worth learning (in my opinion). I’ve also included a short description of why it might be worth learning them. (The list is in no particular order)

If you have an interest in open source, it will not hurt to get a quick base understanding of each of these. I’m not saying you (nor am I trying to) become an expert in each of these tools. However, having a basic understanding of syntax and function should save time and headache while trying to understand a project.

  1. Linux: The concepts in and around Linux are often used on other open source products. I think Open Source developers tend to stick with using open source software. So, there is a link there.
  2. Bash: The de-facto standard shell for Linux (as far as I can tell). Knowing the basic usage of bash can save you time and confusion.  Certain scripts can depend on feature of your terminal interface. The Mac OS X ships with a version of bash, which is good to know…
  3. GCC: This is the GNU Compiler Collection and is often a requirement to build open source packages.
  4. Make: This is a part of the GCC but I want to make special mention of this because knowing how to read the script files and error messages can help diagnose an error.
  5. C / C++: Low Level libraries are often written in C or C++, even for an otherwise Java or Python based program.
  6. Python: Python is sometimes used in conjunction with Make to check for build dependencies, verify (build) requirements, or many other possible things.
  7. Perl: Often used like Python, from what I understand but I’ve yet to learn much about it.
  8. Subversion: This is the most common open source VCS software in use (based on my own observations)
  9. Mercurial: One of the two popular DVCS systems. I’ve noticed more and more open source projects switching to DVCSs, so a basic working knowledge of Mercurial and Git is helpful.
  10. git: The second of the two popular DVCS systems.

If you’d like to contribute to the list, please leave a comment below but please ensure you include a fair reason.

FireFox, Open Source Project, Technologies, Understanding Software , , , , , , , , , , , , ,

Using COALESCE to Build Comma-Delimited String directly in SQL

October 27th, 2009

The following article covers a great should-know piece of information for any SQL Server developer. Though, comma delimited strings are not usually desired in database, it can be nice to receive data this way for things like embedding in to a query string or passing over a web service*.

http://www.sqlteam.com/article/using-coalesce-to-build-comma-delimited-string

*I don’t necessarily suggest the web service idea. I was just saying for illustrative purposes…

SQL Server, Tips

Python Memory Performance

October 8th, 2009

I’ve been studying Python because it is extensively used in open source projects to script certain types of work or actions. I think Mozilla uses it to verify build time requirements, for example.

But, python itself is a full fledged programming language — not really a scripting language. In fact, Mercurial is written in Python which at first amazed me.

So, anyway as part of my pursuit of studying Firefox, I thought I should (at least) learn the basics of Python so that I could read any relevant scripts. Python is quite different from other languages I’ve encountered.

One thing I started to notice about python is that it seems to use more memory. I’m not sure, nor am I suggesting that it uses more than other languages. I just noticed that memory consumption seemed to grow rapidly when running a python script.

The following article seems to explain why. Instantiating a class is expensive. According to the article, a class is 336 bytes. Since in general, a class will use multiple other classes, I can see why memory consumption was growing rapidly.

Ultimately, I don’t think it matters. You just need to be aware that it happens. A modern computer will run the script without any notice to this phenomenon. You’d need to create a lot of objects to cause a problem. But I do beleive it is worth acknowledge that it happens so that you can be aware of the memory usage. It’s mostly noticeable on my work computer (the company provided) which only has 1 GBs of RAM (it runs Windows XP).

http://www.valuedlessons.com/2008/10/blog-post.html

Python, Random, Tips

Undocumented Methods in NSIndexPath – Row, Section

May 11th, 2009

Did you know that the NSIndexPath object apparently has undocumented properties / methods? I’m working on a hobby iPhone OS Application that I hope to release and I’ve been trying to figure out how to use the instances of indexPath provided by: tableView:cellForRowAtIndexPath:

Full protocol:

1
2
tableView:(UITableView *)tableView
    cellForRowAtIndexPath:(NSIndexPath *)indexPath

I was flipping though my iPhone Dev book and was reminded that we have a section method in the instances of indexPath. I just wanted to post this here because this is (at this time) not on apple’s documentation.

Thus far, there are two that I want to mention: section and row.  Both of these most iPhone developers will know about… except if you are new at this… Then this can be perplexing…

1
2
    NSUInteger section = [indexPath section];
    NSUInteger row = [indexPath row];

Technologies, iPhone SDK ,

Great SQL Server Tip

May 8th, 2009

Book Review: Beginning iPhone Development

April 24th, 2009

I’ve been wanting to learn how to develop iPhone applications for a while… Basically since the platform hit the streets. I found out the hard way that you need a Intel based Mac OS X computer to do so.

That left me out in the cold because I didn’t want to buy a Mac Computer just to do this, but I did. I bought a MacBook because I wanted a laptop. On a side note, I love the computer. The hardware is much better than Dell (whose been sliding on the quality of their hardware) and furthermore, Mac OS X is very, very elegant.

Anyway, I dived in to the iPhone SDK with the hopes of getting my first program out the door quickly. While I was able to get programs together and working, the platform is very, very different. To top it all off, the programming language is Objective-C which is quite different from any other language I’ve used.

Beginning iPhone Development: Exploring the iPhone SDK

Beginning iPhone Development: Exploring the iPhone SDK

I was up to the challenge but I needed help, so I recruited a book. The book is: Beginning iPhone Development: Exploring the iPhone SDK by Dave Mark and Jeff LaMarche.

The book was wonderful; I read it cover to cover in about 1 month. There are a few typos but I’m sure they’ll be corrected in a revision release, I’m sure. It is easy to read and easy to follow. I feel I understand everything the book was trying to tell us about. The authors go in to each topic enough for you to understand what they are talking about but they never go so far that they “lose you”.

A wonderful aspect is that their is an active forum to answer questions specifically about your work or learning in the book. Since others have gone though the capture, other readers can normally hep. Though, if all else fails, the authors will help you.

This book won’t make you a master iPhone developer, but it lays a very solid foundation in which to build your skills upon.

Overall, I highly recommend this book for anyone who wants to learn about developing iPhone or iPod touch applications.

iPhone SDK ,

“Windows OOP” vs. “Cocoa MVC”

March 23rd, 2009

While I don’t agree with the following article that windows developers (the author is looking at .NET, I believe) can’t implement the MVC design pattern, I do agree with the article that MVC is probably a better way to implement one’s interface. I want to direct your attention to the following article.

http://www.cimgf.com/2008/07/29/cocoa-tutorial-windows-oop-vs-cocoa-mvc/

.Net, Cocoa, Design Patterns, Design Tip ,

CLR (.NET) Strings in Memory

February 25th, 2009

The following is an interesting article related to how .NET handles strings. I’m not sure if the same thing might apply to Java; I’d be interested to find out.

Anyway, I’m posting this here for safe keeping and to share it…

http://www.simple-talk.com/community/blogs/jcrease/archive/2009/01/16/71678.aspx

.Net, Coding Tip, Technologies, Tips , ,

9 Examples » Fast and Responsive UI (Link)

February 3rd, 2009

One thing I’ve yet to really learn is how to make a well designed responsive user interface in .NET (or any other language).

I came across this article and I thought I’d share it (and save it here for myself). I’ve yet to delve in to Graham’s example but I trust it will be valuable and hence I’m posting it here.

9 Examples of creating a fast and responsive UI with multi-threadinghttp://goneale.wordpress.com/2009/01/27/9-examples-of-creating-a-fast-and-responsive-ui-with-multi-threading/

Graham’s article also points us to another interesting article; an article he recommends: Give Your .NET-based Application a Fast and Responsive UI with Multiple Threadshttp://msdn.microsoft.com/en-us/magazine/cc300429.aspx

.Net, Design Tip, Multi-Threading, Tips

@@SERVERNAME

January 20th, 2009

I was working on a SQL Server project and came across a piece of code that I wanted to only execute if the code was running in production. This is a fairly common problem — code that should only execute if on a specific environment.

Most of the time in my career, I’ve seen people just comment out the code in a given environment. [And yes, I've seen bad mistakes with this method.] While this has obvious potential side effects I didn’t have time to give it much thought… Until recently.

I realized that SQL Server 2000 has a system variable called @@ServerName that will always give you the server name for the active connection.

Using this system variable, you can write some very simple code that will only execute other code in a given environment.

How can you use the variable?

Usage of the system variable (and any system variable) is easy. You can use either Select, Print or any logical statements (such as If or While loops).

All of the following are validate:

1
2
3
4
5
SELECT @@ServerName
PRINT @@ServerName

IF @@Servername = 'Me' BEGIN
END

How to Implement It

How I implemented it was a bit unique; I will first start with a very simple example.

1
2
3
4
5
6
7
Exec ValidateData

IF @@ServerName = 'ProductionSrvr' BEGIN
    UPDATE Users
    SET Processed = 1
    WHERE UserID = @UserID
END

To quickly walk though this code, it is executeing a stored procedure call ValidateData and then we check the @@ServerName variable to find if it matches “ProductionSrvr”. If @@ServerName does, it will execute the update; otherwise the code would go right over the if. This would be great if you didn’t want to update the Users table in the staging or development environments but you did in production.

My twist on implementation

My primary employer does a thing where they lease their servers (and desktop stations) from a provider. The leases expire every 4 years. This means that every four years we migrate databases and web servers to new machines (or virtual machines, as of recent). To my knowledge, we have hundreds of Servers, serving all sorts of software and information (Web sites, databases, Cubes, etc)

Since our SQL Servers are no exception, I wanted to be prepared for such a switch but I still wanted to implement this because of it’s obvious benefits.

I obviously didn’t want to do a find and replace on all of my Stored Procedures and DTS packages (don’t ask) and so I used a function to check the @@ServerName variable against. The function was simple and an example definition follows:

1
2
3
4
5
6
CREATE FUNCTION dbo.fn_ExampleServer ()
RETURNS VARCHAR(100)
AS
BEGIN
    RETURN 'ExampleServer' --Simply return a constant with the server's name
END

My @@ServerName example above would simply become:

1
2
3
4
5
6
7
EXEC ValidateData

IF @@ServerName = dbo.fn_ExampleServer() BEGIN
    UPDATE Users
    SET Processed = 1
    WHERE UserID = @UserID
END

That’s it! I hope others will find this useful.

Coding Tip, Design Tip, SQL Server, Tips , , , , ,