Currently, it is a RDBMs anti-pattern, some people are trying to use the old “not only SQL” definition, but I prefer the “non relational” instead.
There are of course more detailed definitions. For an easy understanding, any modern, non-relational, schema-free, web-scalable, with easy replication support, that don’t use SQL language to interface with it, will fit in the NoSQL field.
There are quite a few categories of NoSQL databases, grouped by characteristics like: Columns, Documents, Tuples, Key Values, Graphs, and others.
I have been working with relational databases associated with ECMs in applications almost all my professional life. When I hear from NoSQL databases a few years ago, the Documents category sparks my imagination.
Two of them have become trends in the field: CouchDB and MongoDB.
Being strictly honest, I have a predilection for MongoDB.
In another recently experienced situation, I feel like in a "back to the past" movie.
Let me show you how that feeling arises:
Working for the Enterprise, there is always a chosen hardware and of course a chosen development environment. I have already posted about customer's decision around being IE6 the standard browser to be considered when developing applications in the previous post.
Considering the hardware, I have recently involved in a situation where the chosen hardware simply didn't support the chosen software options.
We have basically two models of PCs coming from a big enterprise supplier. One of them have an on board video controller (let's call it the X320 model), and the other an off board more specialized video controller (this one could be the X330 model).
Our principal customer site consists mainly of shades of red and gray, but the problem appears more easily with a variety of different tones of gray.
The question is: using the customer's standard CSS plenty of gray tones, many of those tones are simply ignored by X320's video controller, but appear fine when using the X330's one.
This situation brings me back to the old "safe web color" time, and proves me that in the "safe way"; there are no many safe gray options.
If you have any question or need more information, I have compiled information about HTML Colors in general and specifically about gray scale here.
But I have recently experienced a situation where if I was in a more up to date development environment, none of them will surpass simple HTML and CSS.
Let me show how that application should work:
First of all, unfortunately, we need to use tables in these apps.
We have a set of images in a Thumbnail.
When one of the Thumbnail images is clicked a corresponding centered larger image will be displayed at the bottom of the page.
I have defined a fixed width of this larger image in 750px.
I was counting with the height being automatically and proportionally set considering that width.
Everything works fine in all browsers, except when images are narrow then that preset limit.
In that case the centered larger image becomes distorted. The narrow the image compared with the preset width the more obvious becomes the distortion.
You can see an example of how it not properly works here.
On the other hand the solution to that was amazingly simple. Simple as 2 lines of CSS code!
But there is a problem… As always that simple amazing solution doesn’t work on IE6 (in fact it doesn’t work in IE at all). If you are testing the above example in IE, try the last image and see what happens.
Believe it or not, many customers around (at least here in Brazil) are using that infamous browser as the “official” one, and developers should base their web applications on it.
That is only one of the many situations where you should care about Javascript, Jquery and Prototype. They will help you a lot.
Since this is not so complicated, Jquery and Prototype are not necessary. Just a couple of Javascript functions have solved the problem.
Here is a working solution tested against IE6, IE8 and some real modern Browsers like Firefox, Safari, Opera and Chrome.
I would like to see some Jquery and Prototype alternatives to get the same, on an even simpler solution.
A clever solution and there is extremely simple to get it working.
Let’s see:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
So, it is time to give XHTML a break, and start learning HTML 5 and CSS 3.
Of course we have many other HTML5 references on web; here is my first attempt into HTML5.
First things first: the Doc Type declaration.
Compared with my previous one:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
It couldn’t be more appropriate, simple and easy:
<!DOCTYPE html>
What we have been doing using the div tag, could now be done more semantically with, article, section, header, footer, nav and aside tags.
A few phrasing elements can help when including complementary information like: time meter and progress tags.
And a lot of new resources to be explored in the near future, like: video, audio, data attributes, microdata, native drag and drop, canvas, DOM storage, Client side SQL, new form controls, and some more.
At this point I need to do something practical, so, why not turning my own personal page into HTML5. Good chance to change its outdated design and a few concepts.
Hands on!
Here are the steps I have followed:
First, take the former page and a few ideas on what to change.
And here is the altered page:
It was an intermediary version, a cleaner one, but still using XHTML.
Things are going faster and faster, so, why still measuring times in a second precision?
Could you think about how many files are uploaded from users in a specific city within a second?
Let’s say, any country capital with a high speed broadband service.
Try to put them all in order. Which arrives first?
Most of the current relational databases support Timestamp data:
Oracle ........ '2007-08-08 09:00:00.123456789'
DB2 ........... '2002-10-20-12.00.00.123456'
PostgreSQL .... '2003-07-29 13:19:30.532'
MySQL ......... '1970-01-01 00:00:00'
But most of it doesn’t consider nanoseconds properly.
People tend to consider that only Real Time Systems have better precision of time measurement needs, but that is not true.
I have recently developed a business application where users can upload files.
Files are uploaded in groups (fifteen maximum). It was important to know the order on which files have been upload.
Depending on the size of the files and users’ internet broadband capacity, some files could be uploaded in the same second.
So, that is the reason to store the uploaded date in the table as a Timestamp column.
The problem starts when trying to feed the required data using the language resources only. I know we can provide current timestamp from the database itself, but if you are not using a relational database and needs to store the timestamp?
Java and Python for instance, have nanoseconds support, but deal with them separately from the date and time. And about Ruby?
The Good new is that Ruby 1.9 does the job nice this way:
Time.now.strftime('%Y-%m-%d-%H:%M:%S.%6N')
Where you can specify the desired precision in %3N, %6N or %9N, but will need a superfast machine to test them all.
Here is a working sample:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Another consideration you must take into account: the O.S. used:
Solaris and Linux already support nanosecond precision.
The situation on Mac OSX is not that good, since only microseconds are available.
Windows, on the other hand, supports nanoseconds, but have a 10ms granularity limit.
So, depending on O.S. running your code, you may need some extras to get the timestamp in the complete form.
The Bad new is that Ruby 1.8 doesn’t support nanoseconds.
Back to the real World, we must admit that most of people out there are using Ruby 1.8.6 under Windows.
So, I have made a working snippet for Ruby 1.8.6 on Windows that could at least, provide data to the PostgreSQL centisecond format.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Parentheses (singular, Parenthesis)—sometimes called Round Brackets, Curved Brackets, Oval Brackets, or just Brackets, or, colloquially, Parens.
Contain material that could be omitted without destroying or altering the meaning of a sentence.
I think the above definition, must be considered when discussing about the non mandatory Parentheses use in Ruby.
On many discussion groups, people are questioning Matz’s option to not make the use of parentheses mandatory in Ruby Language, mostly around Ruby methods parameters.
Apparently this decision is becoming stronger.
If you run the following piece of code in Ruby 1.8.6, you will get a warning:
p Array.new 3, 1
ptest01.rb:1: warning: parenthesize argument(s) for future version
The same occurs with this one:
p Array.new (3+1), 1
ptest02.rb:1: warning: don't put space before argument parentheses
But if you run them in Ruby 1.9.1 they will pass with no warnings.
Do you really think it would be better this way?
p(Array.new((3+1), 1))
When developing an application I like to put myself in the user’s shoes.
As a user of a reading text (program), I would like to read it easily.
Some times the absence of a rule is not that good.
But the strict use of a rule could be bad as well.
I have this little example:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In Ruby, a Symbol is a special class used to define a constant named label.
A symbol is defined using a colon ":" in the beginning.
Example:
:my_test_symbol
A symbol is not a string, but it has a string representation and an object identifier.
Ruby newbies ask about advantages on using constants over variables, or symbols over both, very often.
First of all, you must know there are no really Constants in Ruby. They are just a convention on variable names (starting with uppercase letters).
You can in fact, change the "constant" values along your ruby program.
That way, it is your responsibility to keep your Ruby "constants" with the same value almost all the time.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Strings, even with the same content are different objects, so, are identified differently.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
So, strictly technically speaking, Symbols are pointers to memory objects containing the symbol name.
Differently from Ruby variables or even Ruby "constants", Symbol values could not be changed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In fact you couldn’t even access the Symbol content unless through a Symbol#to_s method.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Which are the advantages and drawbacks from one over the other?
If you have a few unique string values, and will use them the way they are (no concatenation, upper or lower case, no nothing), Symbols are the right tool for the job.
In any other circumstance, stick with strings. They are not that much slower then Symbols, and much more flexible.
Symbol scope is a bit different and need to be considered.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
About performance, you need to have a few points in mind when dealing with a great amount of strings and Symbols:
About memory:
Strings are Garbage collected, Symbols are not.
So, Symbols will be there while your program is running, which can be a great memory consumer.
Have you ever considered how many objects you will have when you set a variable inside a loop?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
When creating a great amount of Strings and Symbol, how did the operation compares in performance?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
When you make Strings comparison rather then Symbols comparison, it could be a great CPU time consumer, since the comparison must be done for each character in the string.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Symbol "values" can be retrieved in many different ways:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Symbols should be used whenever referring to a name (identifier or keyword), even if that name doesn’t exist in actual code yet.
Naming keyword options in a method argument list
Naming enumerated values.
Naming options in an option hash table.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters