Tuesday, March 17, 2020

ObjectOriented Programming vs Procedural Programming essays

ObjectOriented Programming vs Procedural Programming essays It was way back in the 1970s when Kernighan and Ritchie were working on creating a new programming language they would soon call C. It was called this because a language called B preceded it. C was created with simplicity and flexibility in mind. Its primary use was for writing operating systems, however it became popular for a wide variety of other programs. The one thing that C lacked was support for objects; it was a procedural-oriented program. In a procedural-based programming language, a programmer writes out instructions that are followed by a computer from start to finish. This kind of programming had its advantages, but an object-oriented language makes programming clearer and easier to understand. Object-oriented software is all about using objects. An object actually contains code (member functions) and data (data members). Traditionally, code and data have been kept apart. For example, in the C language, units of code are called functions, while units of data are called structures. Functions and structures are not formally connected in C. A C function can operate on more than one type of structure, and more than one function can operate on the same structure. In object-oriented programming, code and data are merged into a single indivisible thing an object. This has some big advantages. A primary rule of object-oriented programming is this: as the user of an object, you should never need to peek inside the box. The way objects work are that a message is sent in and the object knows how to handle it. Thus the user never needs to see the implementation details. By not knowing what is going on inside an object, the user is unable to change the internal implementation code. Providing access to an object only through its messages, while keeping the details private is called encapsulation. The benefits of objects do not stop with encapsulation. Objects also have the special ability to inherit...

Sunday, March 1, 2020

The History of Cable Cars and Electric Streetcars

The History of Cable Cars and Electric Streetcars San Franciscan Andrew Smith Hallidie patented the first cable car on January 17, 1861, sparing many horses the excruciating work of moving people up the citys steep roadways. Using metal ropes he had patented, Hallidie devised a mechanism by which cars were drawn by an endless cable running in a slot between the rails which passed over a steam-driven shaft in the powerhouse. The First Cable Railway After gathering financial backing, Hallidie and his associates constructed the first cable railway. The track ran from the intersection of Clay and Kearny Streets along 2,800 feet of track to the crest of a hill 307 feet above the starting point. At 5:00 on the morning of August 1, 1873, a few nervous men climbed aboard the cable car as it stood on the hilltop. With Hallidie at the controls, the car descended and arrived safely at the bottom. Given San Franciscos steep terrain, the cable car came to define the city. Writing in 1888, Harriet Harper declared: If anyone should ask me what I consider the most distinctive, progressive feature of California, I should answer promptly: its cable car system. And it is not alone its system which seems to have reached a point of perfection, but the amazing length of the ride that is given you for the chink of a nickel. I have circled this city of San Francisco, I have gone the length of three separate cable lines (by means of the proper transfers) for this smallest of Southern coins. The success of the San Francisco line led to the expansion of that system and the introduction of street railways in many other cities. Most U.S. municipalities had abandoned horse-drawn cars for electrically powered cars by the 1920s. The Omnibus The first mass transportation vehicle in America was an omnibus. It looked like a stagecoach and was pulled by horses. The first omnibus to operate in America began running up and down Broadway in New York City in 1827. It was owned by Abraham Brower, who also helped organize the first fire department in New York. There had long been horse-drawn carriages in America to take people where they wanted to go. What was new and different about the omnibus was that it ran along a certain designated route and charged a very low fare. People who wanted to get on would wave their hands in the air. The driver sat on a bench on top of the omnibus at the front, like a stagecoach driver. When people who were riding inside wanted to get off the omnibus, they pulled on a little leather strap. The leather strap was connected to the ankle of the person who was driving the omnibus. Horse-drawn omnibuses ran in America cities from 1826 until about 1905. The Streetcar The streetcar was the first important improvement over the omnibus. The first streetcars were also pulled by horses, but the streetcars rolled along special steel rails that were placed in the middle of the roadway instead of traveling along regular streets. The wheels of the streetcar were also made of steel, carefully manufactured in such a way so they would not roll off the rails. A horse-drawn streetcar was much more comfortable than an omnibus, and a single horse could pull a streetcar that was larger and carried more passengers. The first streetcar began service in 1832 and ran along Bowery Street in New York. It was owned John Mason, a wealthy banker, and built by John Stephenson, an Irishman.  Stephensons New York company would become the largest and most famous builder of horse-drawn streetcars. New Orleans became the second American city to offer streetcars in 1835. The typical American streetcar was operated by two crew members. One man, a driver, rode up front. His job was to drive the horse, controlled by a set of reigns. The driver also had a brake handle that he could use to stop the streetcar. When streetcars got bigger, sometimes two and three horses would be used to haul a single car. The second crew member was the conductor, who rode at the back of the car. His job was to help passengers get on and off the streetcar and to collect their fares. He gave the driver a signal when everyone was on board and it was safe to proceed, pulling on a rope that was attached to a bell that the driver could hear at the other end of the car.   Hallidie’s Cable Car The first major attempt to develop a machine that could replace horses on Americas streetcar lines was the cable car in 1873. Converting streetcar lines from horse cars to cable cars required digging a ditch between the rails and building a chamber under the track from one end of the line to the other. This chamber was called a vault. When the vault was finished, a small opening was left at the top. A long cable was placed inside the vault. The cable ran under city streets from one end of  the streetcar line to the other. The cable was spliced into a big loop and was kept moving by a huge steam engine with massive wheels and pulleys located in a powerhouse at the side of the street. The cable cars themselves were equipped with a device that extended down below the car into the vault and allowed the operator of the car to latch onto the moving cable when he wanted the car to go. He could release the cable when he wanted the car to stop. There were many pulleys and wheels inside the vault to make sure the cable was able to go around corners, as well as up and down hills. Although the first cable cars ran in San Francisco, the largest and busiest fleet of cable cars was in Chicago. Most large American cities had one or more cable car lines by 1890. Trolley Cars Frank Sprague  installed a complete system of electric streetcars in Richmond, Virginia, in 1888. This was the first large-scale and successful use of electricity to run a citys entire system of streetcars. Sprague was born in Connecticut in 1857. He graduated from the United States Naval Academy in Annapolis, Maryland in 1878 and began a career as a naval officer. He resigned from the navy in 1883 and went to work for Thomas Edison. Many cities turned to electric-powered streetcars after 1888. To get electricity to the streetcars from the powerhouse where it was generated, an overhead wire was installed over streets. A streetcar would touch this electric wire with a long pole on its roof. Back at the powerhouse, big steam engines would turn huge generators to produce the electricity needed to operate the streetcars. A new name was soon developed for streetcars powered by electricity: trolley cars.