cod-E-mphasis

Code practice – String usage in .NET

Posted in .Net, C#, High Level, Object Oriented, Programming Language by $hiva on April 6, 2009

String in .Net, is an Immutable object (Object cannot be modifed). Hence memory allocated for a string remains even if you alter/modify the string through code, forcing the CLR to create new space for the modified string.

//Code Illustration in C#.Net

string str = ""; //memory created for str and value "" is stored
str = "String is Immutable" //new memory space is allocated for str
                            //and value is stored
str += str  + " in .NET" //Again, new memory allocation

This means more string operation you do with, more memory is occupied, though its with the same string variable. Better approach would be to use StringBuilder to do all appends and get the final output as StringBuilder class provides an efficient way to append. And its mutable.

Also string str = “” and string str = String.Empty is not the same in terms of memory allocation. the first creats an object in the memory and the latter does not. Hence prefer the latter

Avoid ToLower() and ToUpper() in code (Remember strings are immutable)

–Writing code is easy, writing good code is not.  Learn, Implement, Share–

WIMAX ————– THE 4TH GENERATION

Posted in Networking & Related, WIMAX, Wireless Networking by msthecool on April 6, 2009

WiMAX, (802.16e) meaning Worldwide Inter-operability for Microwave Access, is a telecommunications technology that provides wireless transmission of data using a variety of transmission modes, from point-to-multipoint links to portable and fully mobile internet access. The technology provides up to 3 Mbit/s broadband speed without the need for cables. It is a newer standard of wireless networking designed to provide the last mile of high speed internet access to the end user. Some people would call Wimax WiFi on steroids but this would be to broad of an assessment. Wifi was and still will be used in LAN environments for the foreseeable future. WiMax was designed to provide (MAN) Metropolitan Area Access, to homes and businesses.

WiMax base stations will have the ability to provide approximately 60 businesses with T1 access and hundreds of homes with DSL/Cable speed access…in theory. Engineers are stating that WiMax has the capability of reaching 30 Miles but real world testing has shown 4-8 mile working radius. WiMax (MAN) deployments are similar to a WiFi network. First the ISP would have their T3 or higher access. The ISP would then use line of sight antennas (Bridges) to connect to towers that would distribute the non line of sight signal to (MAN) residential/business clients. WiMax line of sight antennas operate at a higher Frequency up to 66mhz. Distribution antennas do not have to be in the line of sight with their clients. Non – line of sight towers operate on a range similar to WiFi . WiMax can operate right next to cell phone towers with no interference. WiMax networks are similar to Wifi in deployment. The Wimax Base station/Tower will beam a signal to a WiMax Receiver. Similar to a WiFi access point sending a signal to a laptop. As far as I can tell laptops will be shipping with Wimax receivers in 2006.

aaaa1

QOS (Quality of Service) is an major issue with WiMax because of the number of people accessing a tower at once. Some would think that a tower could be easily overloaded with a lot of people accessing it at once. Built into the WiMax standard is an algorithm that when the tower/base station is nearing capacity then it automatically will transfer the user to another WiMax tower or cell. Unlike a Wifi clients who have to kind of fight to stay associated with a given access point; WiMax will only have to perform this hand shake at the MAC level the first time they access the network. WiMax is designed for building a network infrastructure when the environment or distance is not favorable to a wired network. Also, WiMax is a cheaper and quicker alternative than having to lay wire. Third world countries will greatly benefit from deploying WiMax networks. WiMax can handle virtually all the same protocols Wifi can including VOIP. African countries are now going to start deploying WiMax networks instead of cell phone networks. Disaster zones can also utilize WiMax giving them the ability to distribute crisis information quickly and cheaply. Militaries are already using wireless technology to connect remote sites. Logistics will be simplified with the ease of tracking with RF technologies. WiMax can also handle Webcams and streaming video which would give commanders eyes on target capability. Just imagine if planes were able to drop preconfigured self deploying WiMax antennas in strategic areas giving troops real time battlefield intel. Armed with wireless cameras, drones and a GPS one soldier would truly be an Army of One.  As WiMax is deployed in more areas theory and real life capabilities of WiMax will come to light. The differences between WiMax and Wifi are simple. Think of a WiMax network as an ISP with out wires, with the signal providing your internet access to your business/ home. Wifi will be used within in your LAN for the near future.

Python: Strings

Posted in High Level, Programming Language, Python by Arnab Guha on April 6, 2009

Hello everyone. I am back with Python again. Let’s try to learn it from the scratch. After reading this post, you will be understood about Strings in Python.

Strings are the basic unit of text in Python. Unlike some other programming languages, a single letter is represented as a one-letter string. Let’s try to understand it using some example code:code1

How It Works:

If you use different quotes, they may look different to you; to the Python interpreter; however all of them can be used in the same situations and are very similar.

Three different types of quotes are used in Python. First, there are the single and double quotes.

Python has one more special way of constructing strings, one that will almost always avoid the entire issue of requiring an escape character and will let you put in new lines as well: the triple quote. If you ever use a string enclosed in three quotes in a row—either single or double quotes, but all three have to be the same kind—then you do not have to worry about escaping any single instance of a single or double quote. Until Python sees three of the same quotes in a row, it won’t consider the string ended, and it can save you the need to use escape characters in some situations. See the 3rd line of code in the above figure.

Putting More than One Strings together:

To put more than one string together you can use ‘+’ operator. Suppose you want to put the two strings “Hello” and “Everyone” together. So use the following code:–

code21

Another way to specify strings is to use a format specifier. It works by putting in a special sequence of characters that Python will interpret as a placeholder for a value that will be provided by you.

code3That %s is the format specifier for a string. Several other specifiers are there. Each specifier acts as a placeholder for that type in the string; and after the string, the % sign outside of the string indicates that after it, all of the values to be inserted into the format specifier will be presented there to be used in the string.

Displaying Strings with Print:

For displaying text, a special feature is built into useful languages, one that helps the programmer display information to users. The basic way to do this in Python is by using the print function:

code4print is a function—a special name that you can put in your programs that will perform one or more tasks behind the scenes. Normally, you don’t have to worry about how it happens. In this case, the print function is an example of a built-in function, which is a function included as a part of Python, as opposed to a function that you or another programmer has written. The print function performs output—that is, it presents something to the user using a mechanism that they can see, such as a terminal, a window, a printer, or perhaps another device (such as a scrolling LED display).

In the next post I will discuss about the Numbers and Operators in Python.

.NET Framework: Introduction

Posted in .Net, Framework by Piyali Sarkar on April 6, 2009

Microsoft’s .NET platform is an entirely new way to build applications including web applications. ASP.Net was built on top of the .NET platform and takes full advantage of the power and flexibility of the .NET  framework.

Advantage of .NET platform

There are a number of powerful features and services within the .NET platform; however there are four in particular that have a great impact on ASP.NET applications. Those are-

  1. OS-Neutral Environment- One of the most important aspects of the .NET platform is that it is essentially operating system neutral. The design of the .NET run time library makes it possible to build both desktop and web solution without ever making direct calls to the underlying operating system at all. This means that ASP.NET developers need to know almost nothing of the windows operating system in order to built and deploy their solutions.
  2. Device Independent- Microsoft has designed the .Net platform’s output to work successfully on a number of different devices.  For example, the ASP.NET run times contain a set of user interface controls (Web Form controls) that automatically query the calling browser or device or device and then emit the proper markup language that will work for the calling device. This means that web application developers no longer are required to write complicated branching code that will send one set of files to Netscape browsers and another set of files to Microsoft Browsers. Just one markup page is needed to support multiple browsers.This device independence takes a big leap forward in the ability to create a single source code library that can run successfully on almost any device.
  3. Wide Language Support- Microsoft has designed the .NET run times to support multiple source code languages. This allows programmers to choose the language they are most comfortable with when creating their solutions. The .NET run times support three Microsoft languages that can be used to build ASP.NET applications: C#, Visual Basic .NET and Jscript .NET. C# is the language Microsoft stuff used to build much of the .NET class libraries themselves. It is an extension of the C++ language that has many similarities with java.There are three more languages that are work for .NET has already been released in some beta form. Those are COBOL .NET, PERL .NET and Eiffel for .NET. There are more than 15 .NET languages announced.
  4. Internet-Based Component Services- Microsoft has built into .NET the ability to treat almost any internet location as a component. The key technology used to accomplish this is XML based SOAP (Simple Object Access Protocol) Services. SOAP offers a standardized message format for passing information between Web servers over the Internet. Microsoft has used this message system to help create a standardized way to send component and type library information between two machines. This is, in effect, a kind of remote procedure calling (RPC) system that works over standard HTTP connections. By utilizing the open standards of SOAP, Microsoft has built into the .NET run time a very simple way to expose components for use across the Internet.

Tagged with: ,

Never Upgrade any Software!

Posted in Linux/Unix, OpenSource, Tools(Windows), Tools(linux/Unix), Windows by Jayanta Karmakar on April 6, 2009

Every year we see that various software companies release several software. Some of those software are so useful, that, we forget that, they will also need to update or upgrade.

For example, Nero. After opening the software in your machine you can see the version of it. It should show 6.x.x or 7.x.x or others. Right? Now, just Google the ‘Nero’. You will find, it is running 9.x.x version in the market.

Take another example, Adobe Acrobat Reader. We use this software for reading the PDF files. Now, open it. What version is it showing? 5? 6? 7? Or 8? Now, again Google the ‘Adobe Acrobat Reader’. It is running version 9 man!! What are you doing?

Go online and upgrade all these software. Open Nero’s website. Just a minute….what is it showing? The setup file of 9.0 version of Nero software is 370.5 MB???  Lol! Are they mad? If the setup is near about 400 MB, then what will be the size, if it installs??? Believe it or not, but it is 1.03 GB!!! Yes, from my personal experience, I am telling you. How horrible!!

In their site, they are saying that this time, Nero has become more user friendly and bla..bla..bla… But, in practical, if you see them, you will be more upset. What had they done? Is this our that Nero? It have become more user ‘foe’ly!  Not only Nero, but take any software.. Adobe Acrobat Reader, DivX, iTunes, Power DVD, Adobe Photoshop etc… you name it! These all are our everyday usable software. Not even software, now a days Operating Systems are also becoming monsters. Windows Vista? The os from Microsoft Corporation? Also have tested Windows 7. The same problem.

Now, lets take a small tour over the cons of these upgrading of softwares.

1. More and more Space: They want more AND more space every day. Previously, I have given an example of the Nero. Now, look at this table:

Name of the Software Previous / Most Used Version with Size Most recent Version with Size
Nero V6.x (<100 MB) V9.x (370.5 MB)
Adobe Acrobat reader V5.0 (<10 MB) V9.0 (>26 MB)
DivX V4.0 (0.7 MB) V6.8 (19.8 MB)
iTunes V4.1 (19.1 MB) V8.0 (65.6 MB)
Power DVD V1.5 (2.6 MB) V8.2 (76 MB)

These are the setup file sizes. Now, after installing, they occupy spaces like this: Nero 9.x = 1.03 GB, Adobe Acrobat Reader 9.0 = 230 MB, DivX 6.8 = 50 MB, iTunes 8.0 = 75 MB (without Quick Time, with Quick Time 100 MB). So, what will you do to your hard disk?

2. Unnecessary Functions: 99.9% of the users of Nero have a primary objective: burning a cd or dvd.  But, in the 9.0 version, you will find several tools that you will never use. For example, the Nero Home. I am sure that, you will never use it, if you have used the Windows Media Center once. More over, they give, a ‘Photoshop’-like software which is much harder in order to use the original Adobe Photoshop. You will find more applications like Nero Media Player. The ‘worst’ media player I (probably, you also!) have seen ever. Some times they provide some more ‘visually’ beautiful user interface (Eg. Nero 9), which looks great but works keen. They not only fail to do the job in time, more over pressures on the hardware of the computer which turns to our next point.

3. High Requirements: Windows Vista said that it will require at least 512 – 768 MB of RAM; however, 1GB is the best for the lowest requirement. Windows 7 has raised a step higher. It is demanding minimum 1GB of RAM. However, they said 2GB of RAM will be a good configuration in case of lowest RAM configuration. It was only the demand of RAM. Now, there remains more hardware: Processors, Hard Disk Space, Mother board, Optical Drive etc. Adobe’s latest Photoshop CS4 says of minimum requirement of 512 MB of RAM. But, in practice, I myself found, 1GB works good instead of 512 MB. But, if you guys could remember, the CS2 version had recommended requirement of 512 MB of RAM and, I myself had experienced, 320 MB was more than sufficient for it. My Intel 845GVSR motherboard with P4 2.4 GHz Processor ran the application very fast!

4. Customers are tester: When you buying a software, they will ensure in 1000 ways that, the software has been tested 10,000 times and rated “best value” by some ‘XXX’ magazine! You also look at that and think good of it and become the ‘bakra’. Coming back home, when you start installing it, the lines of problem starts. And until the software company provides a ‘patch’ or ‘update’, the problem persists. I think because of this since 2001 till today the Windows XP is providing ‘Service Pack 3’, ‘security updates’ and other ‘useful updates’. Not only XP, their last OS Vista had received a ‘Service Pack 1’ in 2008 after launching it in mid 2007. So, why will you buy new software, which has not been tested? Why don’t you use the previous versions of those software?? Here comes our last point.

5. Expensive: While Nero’s original burning software initially was used to given away with the CD-Writers at free of cost, the latest Nero 9 will cost you around US$200(probably). If you had purchased Adobe’s Photoshop CS2 or CS3 previously, then also, you have to buy it with near about US$1000(probably) with some US$100 discount. WHY? Why should I buy these software-monsters with 1000 bucks??

So, from the next time, before upgrading any software or OS, think twice. Don’t just follow the crowd of ‘latest versions’ and buy them. Apply your brain, is there really any need to buy a new software version? Can the Nero 9 burn ‘scratched’ discs?? You know the answer: No. Then why do you buy / upgrade it expending both your Income and the Internet Bandwidth??? Rather learn to use alternatives. Open Source Products. For example, In case of Vista os, use Fedora Core / Ubuntu / Cent OS…. These are FREE, OPEN SOURCE and FREELY UPGRADABLE Os which covers the solutions of all the problems stated above. Try to use ‘FoxIT Reader’ v2.3 (current) 2 free of cost with 3MB setup file size having all the features of Adobe Reader 8 and 9. Use VLC media player. This is also another open source media player software that plays nearly all types of files.  Yes, it is true, that, VLC is upgrading every month, but, that does neither require lots of internet bandwidth nor 100s or 1000s bucks as it is free and the latest version 0.9.8a (probably) has the less than 20 MB setup file; which will replace iTunes, DivX and Power DVD. So, apply your brain and think again before any software/os upgradation.