A Brief Introduction To Fiber Optics Technology

Understanding how fiber optics are made and function for uses in everyday life is an intriguing work of art combined with science. Fiber optics has been fabricated from materials that transmit light and are made from a bundle of very thin glass or plastic fibers enclosed in a tube. One end is at a source of light and the other end is a camera lens, used to channel light and images around the bends and corners. Fiber optics have a highly transparent core of glass, or plastic encircled by a covering called “cladding”. Light is stimulated through a source on one end of the fiber optic and as the light travels through the tube, the cladding is there to keep it all inside. A bundle of fiber optics may be bent or twisted without distorting the image, as the cladding is designed to reflect these lighting images from inside the surface. This fiber optic light source can carry light over mass distances, ranging from a few inches to over 100 miles.

There are two kinds of fiber optics. The single-mode fiber optic is used for high speed and long distance transmissions because they have extremely tiny cores and they accept light only along the axis of the fibers. Tiny lasers send light directly into the fiber optic where there are low-loss connectors used to join the fibers within the system without substantially degrading the light signal. Then there are multi-mode which have much larger cores and accept light from a variety of angles and can use more types of light sources. Multi-mode fiber optics also use less expensive connectors, but they cannot be used over long distances as with the single-mode fiber optics.

Fiber optics have a large variety of uses. Most common and widely used in communication systems, fiber optic communication systems have a variety of features that make it superior to the systems that use the traditional copper cables. The use of fiber optics with these systems use a larger information-carrying capacity where they are not hassled with electrical interference and require fewer amplifiers then the copper cable systems. Fiber optic communication systems are installed in large networks of fiber optic bundles all around the world and even under the oceans. Many fiber optic testers are available to provide you with the best fiber optic equipment.

In fiber optic communication systems, lasers are used to transmit messages in numeric code by flashing on and off at high speeds. This code can constitute a voice or an electronic file containing, text, numbers, or illustrations, all by using fiber optics. The light from many lasers are added together onto a single fiber optic enabling thousands of currents of data to pass through a single fiber optic cable at one time. This data will travel through the fiber optics and into interpreting devices to convert the messages back into the form of its original signals. Industries also use fiber optics to measure temperatures, pressure, acceleration and voltage, among an assortment of other uses.

More C# Functions | Prarmeters | Out & Ref | parameters

More of Function Parameters

Lets look into detail of two more parameters in C# functions , out and ref. Of course , we have seen the usual stuff here. Perhaps we could take a brief look into it again and talk about the difference between variable scope , which I remember , have been posted before too. Nonetheless , lets start.

int userAge; //variable outside the function getAge()

public int getAge(int userId)
{
   int userAge; //variable local to the function getAge()
   // codes to get the age from id
   return userAge;
}

userAge = getAge(12);

As you can see from my comments , although there are two variables called “userAge” , it doesn’t matter , although as a good programming practice , they should have been given different names. It is because on of them is only within the function while the other is within the class or namespace. And of course , the function returns an integer back to the caller. Suppose you want to return two variables , how do we go about doing that? You can only return one value if you write it as above. It won’t work if you coded return statement twice. But suppose you must return two variables.

Function With “out” Parameters

int userAge; //variable outside the function getAge()
int userEnglishGrade;

public void getInfo(out int userAge , out userEnglishGrade)
{
   userAge = 20;
   userEnglishGrade = 2;
}

getInfo(out userAge , out userEnglishGrade);

Console.WrintLN(userAge); //prints out 20
Console.WrintLN(userEnglishGrade); //prints out 2

As you can see , by using out , I can return the two variables , after assigning them with respective values. Of course , it doesn’t return anything because it is a “void” method. Pls take not that my out variables , userAge and userEnglishGrade were not initialised. They were only declared. Initializing takes place in the function which then returns them to the caller , in this case , the program. We now take a look at the parameter using ref keyword.

Function With “ref” Parameters

int userAge = 10; //variable outside the function getAge()
int userEnglishGrade = 2;

public void getInfo(ref int userAge , ref userEnglishGrade)
{
   userAge = 20;
   userEnglishGrade = 3;
}

Console.WrintLN(userAge); //prints out 10
Console.WrintLN(userEnglishGrade); //prints out 2

getInfo(ref userAge , ref userEnglishGrade);

Console.WrintLN(userAge); //prints out 20
Console.WrintLN(userEnglishGrade); //prints out 3

It looks almost the same as the out example above with a few exceptions. With ref , you are going to have to initialize the variable before calling the function whereas with out , you do so within the function. What ref does is that the address of the variable passed on is used to make the changes , which means the variable is directly updated within the function. If you have done any C programming before and it sounds similar to pointers , well then it is. In any case , for most of the time , you would probably be using the standard function with wither void or return.

Function Parameters Conclusion

Hope this clear up on the function parameters in C#. It isn’t as easy as my previous posts so if you didn’t get it the first time , don’t give up! Read , again and again a few more times and I am sure you will get it eventually. Cya!

Classes & OOP | Object

Historical Object

Today being the Sunday and all , I am not interested in writing anymore codes. Lets talk about a programming paradigm. OOP or Object Oriented Programming as has been available since Smalltalk-80. In fact Smalltalk , if you don’t know what is it , here is the link to wiki , is described as more object-oriented than C++/Java. Don’t worry , we won’t be going into details on why it is more OOP or why it is not. Take this as a more of historical value than any thing else.

So why is OOP so popular and why should you use it? Well , if you are writing a program to display some values on the web or on desktop, there isn’t much different between any of the programs. You would likely be using keywords such as as “echo” , “printf” , “Console.WriteLine” or any other variations , depending on your language. But if you are designing a software , how you look at it becomes as important or even more important than writing codes.

Bedtime Object Stories

To illustrate , to the best of my abilities , lets do a story on object. When we were talking about functions and how they work , I made up a story about cooking a meal. Lets do the same thing for OOP as well.

A Person As An Object

We can think of a person as an object and what we do actually. What do you do when you see a house burning? You would call a fire-station expecting fire-man to put down the flames. When you are sick , you would go to a doctor. So instead saying

FireAlert(NewYork);
CallDoc(Flu);

You would think of it as ,

FireMan.Rescue(NewYork);
Doc.Cure(Flu)

So instead of writing a block of codes that does something , you are saying that this block of code is an ability of a function of an object. In fact , that what we been doing all along. “System.Console.WriteLine” is about an class called “System” that has a sub-class “Console” which has a method or a function called “WriteLine”.

So in most textbooks , this way of classes with sub-classes would be called “Grandfather-Father-Child” example. In our example , we could put our firemen and doctors as

Person.Fireman
Person.Doctor

And of course , both firemen and doctors would have similar attributes and abilities such as

Person.Name
Person.Address
Person.Age
Person.Sex
.
.
.
Person.run
Person.walk
Person.swim
.
.
.

But there would also be something that firemen could perform but doctors could not and vice versa

Person.Fireman.Rescue
Person.Doctor.Cure

And somethings both won’t be able to do or have

Person.Fly
Person.ThirdLeg

To Conclude A Lesson In Object & Classes

If you didn’t get any of my words , don’t despair! IMHO , OOP is much more clearer if you are coding. Thats what we be doing for next few days so be sure to come back and check the site! Cheers!!

Functions In-Depth | function

*FYI : I am using the word “function” here but pls note that “function” and “method” can be used interchangeably.*

Last Of The Function

Alright , this would be the last of the topics on functions I promise. In this post , we would be going into 2 main areas , input parameters and return values. So far , our examples involve no more than printing some basic words or numbers using functions. That is actually not how functions are used in real-world. Lets go back to the example about cooking a dish. We could , if we wish , could come up with many functions for cutting ingredients ,

Cooking With Function

Cut-Vege-Function() { ... }
Cut-Meat-Function() { ... }
Cut-Fruit-Function() { ... }

There is absolutely nothing wrong with the above functions. However , you could see just from these three examples that something is very wrong with our logic. If there are more than 3 types of ingredients to be cut , say 100 types , we would have to be creating over 100 similar functions to cut each type. Instead , we could have created a function called “Cut” and give it the type to cut. Like this ..

Cut(Vege) { ... }
Cut(Meat) { ... }
Cut(Fruit) { ... }

Wait , we have not finished our story. What happened to those objects after being cut? Are you going to eat them? Surely not. You probably would prepare them for further steps. Perhaps you might boil the vegetable , bake the meat and freeze the fruit and so on. So lets go back and change our code with “return” statement.

cut-vege = Cut(Vege) { ... return cut-vege; }
cut-meat = Cut(Meat) { ... return cut-meat; }
cut-fruit = Cut(Fruit) { ... return cut-fruit; }

Of course , you would notice that there are two variables here , one of them is inside the function and the other outside it. I wrote this with the intend of going though variables scope/lifetime one more time. Apparently the variable ‘cut-fruit’ within the function ends when the function also ends.

C# Function Example

Here is a function with parameters and a return ,

public int Sum(int x , int y)
{
    return x + y;
}

So you put in two numbers – internally within the function , they are named x and y – and receive an integer which is the sum of the two numbers entered , as the “int Sum” stated. If we are to put

public void Sum(int x , int y)

It means the function would return void or nothing to whoever called it.

Calling a Function

So how do we call a function? As you might have guessed , it depends on what are the parameters and what does it return , if it returns anything at all. Here is how the above example would be called ,

int sum;
sum = Sum(3,5);
Console.WriteLine("The sum of 3 and 5 is : {0}" , sum); //prints out "The sum of 3 and 5 is : 8

This is a more flexible version of the above line allowing you to definte x and y as any numbers and substituting them when compiling the program.

Console.WriteLine("The sum of {0} and {1} is : {2}" , x , y , sum(x,y));

Hope this has given some help to you and you have enjoyed it as much as I have writing this. Cya! Here is an tutorial on basic variable usage if you have not gone though it.

Functions In Practice | function

Lets look at how function is used in practice. We will be using PHP for these examples. For those into theory , pls kindly take a look at my previous post here. To recap , functions or methods are generally used to contain a block of codes in one central location to be used over and over again. It makes development much more efficient and also making changes to the program more easier.

Function’s Syntax

We begin with the general syntax , which looks roughly like this ,

function Name-of-the-function()
{
here goes all the codes
}

Here is an example of the above syntax,


The above will print out “Hello! My name is Jim” to your web browser. It is not terribly exciting and definitely nothing to shout about but its a good start nonetheless. I think even at the start , we can see the power of containing the code into a block. Instead of writing “echo” again and again , we just have to call up the function “hello()” and thats it.

Function Parameters

You could also use the functions to add your own input ,


The code above will prints out ,

My name is George Brown.
My sister's name is Janet Brown.
My brother's name is janet Cheese.

Functions With Return Value

Here is a function that returns an integer to you ,


with the output of ,

10 + 23 = 33
22 + 9 = 31

Final Words On Function

Hope it gives you some information regarding functions and also about PHP programming in general. I will definitely be going into functions again and again in the examples. It is one of the most important and useful tool in the programmer handbag. A good function will save hours of hard work. Till next time , cya!