MongoDB Subcollections

November 23, 2013

Subcollections
One convention for organizing collections is to use namespaced subcollections separated by the . character. For example, an application containing a blog might have a collection named blog.posts and a separate collection named blog.authors. This is for organizational purposes only—there is no relationship between the blog collection (it doesn’t even have to exist) and its “children.”
Although subcollections do not have any special properties, they are useful and incorporated into many MongoDB tools:
GridFS, a protocol for storing large files, uses subcollections to store file metadata separately from content chunks (see Chapter 6 for more information about GridFS).
Most drivers provide some syntactic sugar for accessing a subcollection of a given collection. For example, in the database shell, db.blog will give you the blog collection, and db.blog.posts will give you the blog.posts collection.
Subcollections are a great way to organize data in MongoDB, and their use is highly recommended.

Excerpt From

Kristina Chodorow. “MongoDB_ The Definitive Guide, 2nd Edition.epub.” iBooks.

How to reduce the life of a software defect?

While building software for large projects with zero defects is virtually impossible, the quality of the software can be determined by the lifetime of a defect – the time when a defect is identified, fixed and released. A defect in a well-isolated module can be easily identified, root-cause analyzed and fixed in a short amount of time than a highly cohesive system.

In addition, adopting an agile development methodology helps  reducing the lifetime of a defect drastically. This is possible by releasing well-tested software in short bursts or iterations and delivering higher quality software compared to other development methodologies.

In an agile project, tests are written before or concurrently while producing the code. Therefore, all code that is delivered for testing is tested code. In most agile projects there are four primary layers of testing:

[box]

  • Unit testing, also called development testing.
  • Acceptance testing, also called functional testing.
  • Component testing.
  • System and performance testing – integration testing and testing for non-functional requirements.

[/box]

In agile methodology, the primary goal is to test all these layers during the course of iteration.

Continue reading “How to reduce the life of a software defect?”

What makes a good Solutions Architect agile?

An agile Solutions Architect is someone who values:

  • Individuals and interactions over processes and tools.
  • Building the software collaboratively with the development team over producing comprehensive documentation.
  • Designing a flexible solution anticipating future requirement changes over current requirements
  • Tapering down the flexible solution (described above) to meet time and budget over a solution that is build like a glove from ground up to meet the current requirements, time and budget.

While there is value in the items on the right, a pragmatic solution architect values the items on the left even more.

In addition, to be agile, a Solutions Architect should:

  • Keep the architecture documentation alive by constantly updating it and keeping it current to reflect the current state of the architecture.
  • Welcome requirements change late in the development cycle to support the development of a product in a constantly changing environment.
  • At regular intervals reflect on how to make the architecture more effective and fine tune it to adjust its behavior accordingly.

Documenting the architecture and designs in a centralized repository (such as MEGA) is great, but all those diagrams is meaningless if the Solutions Architect does not proactively work with the Development team to help them understand the vision and patterns evangelized in the blueprints. The most efficient and effective way of conveying that information is through informal face-to-face conversations.

 

Resetting the System Management Controller (SMC) on your Mac

Sometimes my Mac Book Retina Pro’s fan goes on high for no apparent reason. I checked the memory and CPU usage and I cannot find a good reason for the increased RPM of the system fan inspite of adequate ventilation.

Apple has this to say about this issue, “It is possible that the SMC could encounter an issue that may cause unusual system behavior typically related to the symptoms described below. In some cases, resetting the SMC may be the only correct method to resolve the issue”.

Apparently, the only way to solve this is as follows, which to my surprise I found it works.

  1. Shut down the computer.
  2. Plug in the MagSafe power adapter to a power source, connecting it to the Mac if its not already connected.
  3. On the built-in keyboard, press the (left side) Shift-Control-Option keys and the power button at the same time.
  4. Release all the keys and the power button at the same time.
  5. Press the power button to turn on the computer.  
    Note
    : The LED on the MagSafe power adapter may change states or temporarily turn off when you reset the SMC.

 

Recovery Time Objective vs. Recovery Point Objective

RTO & RPO are two non-functional requirements that affect the business continuity management. While RTO has much broader impact, both of these factors should be determined objectively based on the need and cost factor in mind.

picture-for-rto-rpo2I am currently reviewing non-functional requirements for a project I am working on and the topic of Recovery Time Objective (RTO) and Recovery Point Objective (RPO) came up. While both RTO and RPO talks about business continuity, there are subtle differences.
 
RTO determines how quickly a system can recover in case of a disaster. The shorter the time span, the more investment is necessary to recover from an incident. For instance, if the RTO is 60 minutes, backup systems should be ready for a seamless switch over. System configurations should be transparent & decoupled to enable this – meaning, no hard-coding of servers in configuration files etc. Systems should also be replicated at memory and database level to achieve this. Compare this with an RTO of 1 day which provides enough time for switch over manually and the investment is very low. Ofcourse, for today’s production systems an RTO of one day is unacceptable. The point is, if your client is bent on reducing the RTO, they should also be ready to loosen up their purse strings.
 
RPO on the other hand indicates how much work can you affort to lose. For instance, if your system writes to a data store, is it tolerable to lose one hour of work, or four hours of work? The number of hours here is the RPO and helps formulate a strategy for backup. If your RPO is four hours, then you need to perform backup atleast every four hours, but if your RPO is one hour then your backup strategy should match. Ofcourse, this will increase the infrastructure cost.
 
Obviously, RTO has a much broader boundary as it impacts business continuity management, while RPO is focused on backup frequency. Regardless, these number should be determined objectively based on the need and cost factor.

Renaming a file on Mac

Renaming a file on a Mac is not so obvious; plus an Automator script to rename files.

mac-rename

One would think that renaming a file on Mac must be easy given the user-friendliness of Mac OS. Turns out, it is not so obvious.

To rename a file in Finder, you click on the icon preceding the file name once and then click on the file name again. This will highlight the file minus the extension. Now you can type the new name to rename.

Having said that, I was able to create a Automator script that will pop-up a dialog to rename either part of the file (base or extension) by right-clicking and selecting the Services option.

Following is the snapshot of the Automator script.

Automator Script

 

What is MongoDB

Main features of MongoDB

Mongodb

MongoDB is an open source, document-based database management system. Designed for the data and scalability requirements of modern internet applications, MongoDB features dynamic queries and secondary indexes; fast atomic updates and complex aggregations; and support for replication with automatic failover and sharding for scaling horizontally.

Document Databases

Explores the difference between the leading document databases, CouchDB and MongoDB

mongodb.pngExcerpt from Mongo DB in Action – “Few databases identify themselves as document databases. The other well-known document database apart from MongoDB is Apache’s CouchDB.

CouchDB’s document model is similar, although data is stored in plain text as JSON, whereas MongoDB uses the BSON binary format.

Like MongoDB, CouchDB supports secondary indexes; the difference is that the indexes in CouchDB are defined by writing map-reduce functions, which is more involved than the declarative syntax used by MySQL and MongoDB.

They also scale differently. CouchDB doesn’t partition data across machines; rather, each CouchDB node is a complete replica of every other.”

 

What? Which Continent is that?

I picked up a DVD titled, “Animal Passport” from Redbox the other day to watch with my kids. It is a documentary profiling various animals in different continents. With the discussion about continent we have opened a can of worms. There is a lot of confusion about what makes a continent. There are currently five models (as per Wikipedia) to describe continents. The following is a list of models from http://en.wikipedia.org/wiki/Continent. While none of this discusses the sixth model which names Oceania to hold the countries of Australia, New Zealand, New Guinea and the other sundry islands or the seventh one which substitutes Australasia for Oceania which includes  Australia (as we know it) and New Zealand (Note: Asia is not included in Australasia even though the name contains asia).
 
Models

Color-coded map showing the various continents. Similar shades exhibit areas that may be consolidated or subdivided.

7 continents
[13][14][15][16][17][18]
 North America South America Antarctica Africa Europe Asia Australia
6 continents
[14][19]
North America South America Antarctica Africa Eurasia Australia
6 continents
[20][21]
America Antarctica Africa Europe Asia Australia
5 continents
[19][20][21]
America Antarctica Africa Eurasia Australia
4 continents
[19][20][21]
America Antarctica Afro-Eurasia Australia

Australia – the continent that started this whole discussion seems to hold only Australia by itself if you go by Model 1 (7 continents) – the model I learnt growing up and one which is based on the logic of dividing continents by continental shelf. So the logical question is what happens to New Zealand? It turns out that this belongs to the continent of Zealandia (because it is in a different continental shelf). But, wait a second, where is Zealandia?, you ask. Unfortunately, Zealandia is a submerged continent, so you cannot see it. Convenient, eh!

So it appears the concept of continent is different depending on which continent you are from 🙂

The seven-continent model is usually taught in Western Europe, Northern Europe, Central Europe, Southeastern Europe, China and most English-speaking countries. The six-continent combined-Eurasia model is preferred by the geographic community, Russia, Eastern Europe, and Japan. The six-continent combined-America model is taught in Latin America, and some parts of Europe including Greece, Portugal and Spain. This model may be taught to include only the five inhabited continents (excluding Antarctica)”

If that was fun, I will let you look up the idea behind Super Continent which now only has one member, “Eurasia”.

Converting PDF to Word Format for Editing

In an earlier post, I described how to use cups-pdf to print documents directly to PDF in Ubuntu 9.04. While playing around with cups-pdf, I discovered kword. This nifty piece of editor software allows you to convert PDF files to a format that could be edited. You can then convert it to PDF format again by ‘printing’ it to PDF using cups-pdf.

To get started, you have to install kword using the following:

sudo apt-get install kword

Now you invoke it using:

Applications -> Office -> kword

Here, use the File -> Import feature to import any PDF file into it. Happy editing!

Note: If the PDF is password protected, kword allows you to enter the password to decrypt it.