Sunday, May 17, 2020

Overrides in VB.NET - Using VB.NET Series

This is one of a mini-series that covers the differences in Overloads, Shadows, and Overrides in VB.NET. This article covers Overrides. The articles that cover the others are here: - Overloads- Shadows These techniques can be hugely confusing; there are a lot of combinations of these keywords and the underlying inheritance options. Microsofts own documentation doesnt begin to do the topic justice and there is a lot of bad, or out of date information on the web. The best advice to be sure that your program is coded correctly is, Test, test, and test again. In this series, well look at them one at a time with emphasis on the differences. Overrides The thing that Shadows, Overloads, and Overrides all have in common is that they reuse the name of elements while changing what happens. Shadows and Overloads can operate both within the same class or when a class inherits another class. Overrides, however, can only be used in a derived class (sometimes called a child class) that inherits from a base class (sometimes called a parent class). And Overrides is the hammer; it lets you entirely replace a method (or a property) from a base class. In the article about classes and the Shadows keyword (See: Shadows in VB.NET), a function was added to show that an inherited procedure could be referenced. Public Class ProfessionalContact ... code not shown ... Public Function HashTheName( ByVal nm As String) As String Return nm.GetHashCode End Function End Class The code that instantiates a class derived from this one (CodedProfessionalContact in the example) can call this method because its inherited. In the example, I used the VB.NET GetHashCode method to keep the code simple and this returned a fairly useless result, the value -520086483. Suppose I wanted a different result returned instead but, - I cant change the base class. (Maybe all I have is compiled code from a vendor.) ... and ... - I cant change the calling code (Maybe there are a thousand copies and I cant update them.) If I can update the derived class, then I can change the result returned. (For example, the code could be part of an updatable DLL.) There is one problem. Because its so comprehensive and powerful, you have to have permission from the base class to use Overrides. But well-designed code libraries provide it. (Your code libraries are all well designed, right?) For example, the Microsoft provided function we just used is overridable. Heres an example of the syntax. Public Overridable Function GetHashCode As Integer So that keyword has to be present in our example base class as well. Public Overridable Function HashTheName( ByVal nm As String) As String Overriding the method is now as simple as providing a new one with the Overrides keyword. Visual Studio again gives you a running start by filling in the code for you with AutoComplete. When you enter ... Public Overrides Function HashTheName( Visual Studio adds the rest of the code automatically as soon as you type the opening parenthesis, including the return statement which only calls the original function from the base class. (If youre just adding something, this is usually a good thing to do after your new code executes anyway.) Public Overrides Function HashTheName( nm As String) As String Return MyBase.HashTheName(nm) End Function In this case, however, Im going to replace the method with something else equally useless just to illustrate how its done: The VB.NET function that will reverse the string. Public Overrides Function HashTheName( nm As String) As String Return Microsoft.VisualBasic.StrReverse(nm) End Function Now the calling code gets an entirely different result. (Compare with the result in the article about Shadows.) ContactID: 246 BusinessName: Villain Defeaters, GmbH Hash of the BusinessName: HbmG ,sretaefeD nialliV You can override properties too. Suppose you decided that ContactID values greater than 123 would not be allowed and should default to 111. You can just override the property and change it when the property is saved: Private _ContactID As Integer Public Overrides Property ContactID As Integer Get Return _ContactID End Get Set(ByVal value As Integer) If value 123 Then _ContactID 111 Else _ContactID value End If End Set End Property Then you get this result when a larger value is passed: ContactID: 111 BusinessName: Damsel Rescuers, LTD By the way, in the example code so far, integer values are doubled in the New subroutine (See the article on Shadows), so an integer of 123 is changed to 246 and then changed again to 111. VB.NET gives you, even more, control by allowing a base class to specifically require or deny a derived class to override using the MustOverride and NotOverridable keywords in the base class. But both of these are used in fairly specific cases. First, NotOverridable. Since the default for a public class is NotOverridable, why should you ever need to specify it? If you try it on the HashTheName function in the base class, you get a syntax error, but the text of the error message gives you a clue: NotOverridable cannot be specified for methods that do not override another method. The default for an overridden method is just the opposite: Overrideable. So if you want overriding to definitely stop there, you have to specify NotOverridable on that method. In our example code: Public NotOverridable Overrides Function HashTheName( ... Then if the class CodedProfessionalContact is, in turn, inherited ... Public Class NotOverridableEx Inherits CodedProfessionalContact ... the function HashTheName cannot be overriden in that class. An element that cannot be overridden is sometimes called a sealed element. A fundamental part of the .NET Foundation is to require that the purpose of every class is explicitly defined to remove all uncertainty. A problem in previous OOP languages has been called â€Å"the fragile base class.† This happens when a base class adds a new method with the same name as a method name in a subclass that inherits from a base class. The programmer writing the subclass didnt plan on overriding the base class, but this is exactly what happens anyway. This has been known to result in the cry of the wounded programmer, I didnt change anything, but my program crashed anyway. If there is a possibility that a class will be updated in the future and create this problem, declare it as NotOverridable. MustOverride is most often used in what is called an Abstract Class. (In C#, the same thing uses the keyword Abstract!) This is a class that just provides a template and youre expected to fill it with your own code. Microsoft provides this example of one: Public MustInherit Class WashingMachine Sub New() Code to instantiate the class goes here. End sub Public MustOverride Sub Wash Public MustOverride Sub Rinse (loadSize as Integer) Public MustOverride Function Spin (speed as Integer) as Long End Class To continue Microsofts example, washing machines will do these things (Wash, Rinse and Spin) quite differently, so theres no advantage of defining the function in the base class. But there is an advantage in making sure that any class that inherits this one does define them. The solution: an abstract class. If you need even more explanation about the differences between Overloads and Overrides, a completely different example is developed in a Quick Tip: Overloads Versus Overrides VB.NET gives you even more control by allowing a base class to specifically require or deny a derived class to override using the MustOverride and NotOverridable keywords in the base class. But both of these are used in fairly specific cases. First, NotOverridable. Since the default for a public class is NotOverridable, why should you ever need to specify it? If you try it on the HashTheName function in the base class, you get a syntax error, but the text of the error message gives you a clue: NotOverridable cannot be specified for methods that do not override another method. The default for an overridden method is just the opposite: Overrideable. So if you want overriding to definitely stop there, you have to specify NotOverridable on that method. In our example code: Public NotOverridable Overrides Function HashTheName( ... Then if the class CodedProfessionalContact is, in turn, inherited ... Public Class NotOverridableEx Inherits CodedProfessionalContact ... the function HashTheName cannot be overriden in that class. An element that cannot be overridden is sometimes called a sealed element. A fundamental part of the .NET Foundation is to require that the purpose of every class is explicitly defined to remove all uncertainty. A problem in previous OOP languages has been called â€Å"the fragile base class.† This happens when a base class adds a new method with the same name as a method name in a subclass that inherits from a base class. The programmer writing the subclass didnt plan on overriding the base class, but this is exactly what happens anyway. This has been known to result in the cry of the wounded programmer, I didnt change anything, but my program crashed anyway. If there is a possibility that a class will be updated in the future and create this problem, declare it as NotOverridable. MustOverride is most often used in what is called an Abstract Class. (In C#, the same thing uses the keyword Abstract!) This is a class that just provides a template and youre expected to fill it with your own code. Microsoft provides this example of one: Public MustInherit Class WashingMachine Sub New() Code to instantiate the class goes here. End sub Public MustOverride Sub Wash Public MustOverride Sub Rinse (loadSize as Integer) Public MustOverride Function Spin (speed as Integer) as Long End Class To continue Microsofts example, washing machines will do these things (Wash, Rinse and Spin) quite differently, so theres no advantage of defining the function in the base class. But there is an advantage in making sure that any class that inherits this one does define them. The solution: an abstract class. If you need even more explanation about the differences between Overloads and Overrides, a completely different example is developed in a Quick Tip: Overloads Versus Overrides

Wednesday, May 6, 2020

Signs, Symbols and Signals of the Underground Railroad Essay

Signs, Symbols and Signals of the Underground Railroad A journey of hundreds of miles lies before you, through swamp, forest and mountain pass. Your supplies are meager, only what can be comfortably carried so as not to slow your progress to the Promised Land – Canada. The stars and coded messages for guidance, you set out through the night, the path illuminated by the intermittent flash of lightning. Without a map and no real knowledge of the surrounding area, your mind races before you and behind you all at once. Was that the barking of the slavecatchers’ dogs behind you or just the pounding rain and thunder? Does each step bring you closer to freedom or failure? The Underground Railroad was an escape network of small,†¦show more content†¦Mr. Still was unusual in that he kept careful, written records of those he assisted, including short biographies on some, which he published in 1872. Mr. Still often employed railroad metaphors in his writing. The following example illustrates the way messages were encoded so that only those active in the railroad would fully understand their meaning, even if intercepted by outsiders: â€Å"I have sent via a two o’clock four large and two small hams,† which indicated that four adults and two children were being sent by train from Harrisburg to Philadelphia.† (Wikipedia, Underground Railroad) The use of the word via was to indicate that they were not sent on a regular locomotive, but via Reading, PA. In this case the authorities went to the train station in Philadelphia with the hopes of intercepting the fugitives, allowing Still’s agent to meet them in Reading and escort them to safety. Some preachers, friends of the cause, were said to have encoded their sermons to inform select parishioners of the arrival and departure of fugitives over the course of the coming week. Some wore a specific colored handkerchief in their pocket to indicate a meeting to be held or impending arrival of fugitives. As a matter of necessity, stationmasters were accustomed to knocks on their doors or windows at odd hours of the night. The response to the question of â€Å"Who’s there?† wasShow MoreRelatedThe Cold War And The Soviet War1982 Words   |  8 Pagesthe west Berlin and lost their live on their way to west Berlin, and many peoples’ lost their families’, separated from their family and lost their jobs as well. I also, learned the thousands of people escaped by the hot air balloons, building underground tunnels and breaking the barricades with their cars. All this was costs by the wall which were build and separated many families’ and killed many of them, and their is one good thing about this is that no there was no weapons which were used inRead MoreSantrock Edpsych Ch0218723 Words   |  75 Pageshad walked home before. Yet another characteristic of preoperational children is that they ask a lot of questions. The barrage begins around age three. By about five, they have just about exhausted the adults around them with â€Å"Why?† â€Å"Why† questions signal the emergence of the child’s interest in figuring out why things are the way they are. The Concrete Operational Stage The concrete operational stage lasts from about 7 to about 11 years of age. Concrete operational thought involves using operationsRead MoreContemporary Issues in Management Accounting211377 Words   |  846 Pagessense-making more generally. A description of performance management as an organizational capability (Barney et al. 2001) was given by Ahrens and Chapman (2002). In the restaurant chain that they studied, performance metrics did not produce unequivocal signals for action but formed a potential basis for discussion. In their study they explored in detail the complex ways in which selective attention to diVerent sets of performance measures formed the basis of ongoing trade-oVs between various sources ofRead MoreLangston Hughes Research Paper25309 Words   |  102 PagesClarks left for Chicago, and Langston went to live with James and Mary Reed, his grandmothers friends. Auntie and Uncle Reed treated Langston like the son they never had. They raised a garden, and kept a cow and chickens on their property near the railroad tracks, so for the first time in his life, teenage Langston had plenty to eat. On Sunday, Auntie Reed spent the day at church, but Uncle Reed did not. Weekdays, he worked as a ditch digger for a plumber. On Sundays he washed his work overalls inRead MoreLogical Reasoning189930 Words   |  760 Pages(Prediction) ................................................................................ 434 Appeal to a Typical Example ....................................................................................................... 435 Argument Based on Signs ............................................................................................................. 437 Causal Inference ...................................................................................................................Read MoreOne Significant Change That Has Occurred in the World Between 1900 and 2005. Explain the Impact This Change Has Made on Our Lives and Why It Is an Important Change.163893 Words   |  656 Pagesboth nuclear power generators and atomic weaponry, and they also examine the ways that advances in these enmeshed fields of scientific and technological endeavor became emblematic in the cold war decades of national power and prestige, as well as symbols of modernity itself. They go well beyond the usual focus on the two superpowers INTRODUCTION †¢ 7 to look at â€Å"nuclear politics,† which encompasses both state initiatives and popular dissent, in former but diminished national great powersRead MoreImpact of Science on Society38427 Words   |  154 Pagesthis cognitive model, both at the individual level and at the level of whole societies. Both kinds of models are very idiosyncratic. The Italian model has a sign like a wave, meaning, â€Å"Come here.† Greek girls cause problems for non-Greek boys by saying â€Å"No† with a nod, not a shake, of their head. In New Zealand you can do one kind of V-sign but never the other. Americans look posh when they look neat; Europeans look posh when they look as if they’ve just come through a hedge backwards. A very fineRead MoreImpact of Science on Society38421 Words   |  154 Pagesthis cognitive model, both at the individual level and at the level of whole societies. Both kinds of models are very idiosyncratic. The Italian model has a sign like a wave, meani ng, â€Å"Come here.† Greek girls cause problems for non-Greek boys by saying â€Å"No† with a nod, not a shake, of their head. In New Zealand you can do one kind of V-sign but never the other. Americans look posh when they look neat; Europeans look posh when they look as if they’ve just come through a hedge backwards. A very fineRead MoreHuman Resources Management150900 Words   |  604 Pagesits members’ responses and defines what an organization can or is willing to do. Chapter 2 Strategic Human Resource Planning 43 The culture of an organization is seen in the norms of expected behaviors, values, philosophies, rituals, and symbols used by its employees. Culture evolves over a period of time. Only if an organization has a history in which people have shared experiences for years does a culture stabilize. A relatively new firm, such as a business existing for less than two yearsRead MoreManagement Course: Mba−10 General Management215330 Words   |  862 Pagesthe injured. Although shaken from the crash, the survivors initially were confident they would be found. These feelings gradually gave way to despair, as search and rescue teams failed to find the wreckage. With the passing of several weeks and no sign of rescue in sight, the remaining passengers decided to mount several expeditions to determine the best way to escape. The most physically fit were chosen to go on the expeditions, as the thin mountain air and the deep snow made the trips extremely

Chattanooga Ice Cream free essay sample

Chattanooga Ice Cream Case The Chattanooga Ice Cream case shows a decline in sales for 5 consecutive years. The Division is headed by Charles Moore. Although Charles Moore was successful in leading teams he seemed to have major issues with this team of vice presidents. According to the Harvard Business Review Chattanooga Ice Cream Case the team was very dysfunctional; they exhibited a lack of trust, high in conflict, disrespectful of each other and exhibited avoidance issues with accountability. Team members seemed to always lay blame to other member. Moore needs to be more assertive in dismissing the ways of the past and the loss of Stay Shop business needs to be put aside. Moore needs to give clear direction and assign responsibilities to each team member. Moore needs to convey that team cohesiveness is a must and this will go a long way to help ensure no further loss of business. This paper will examine how Moore’s leadership approach contributed to the teams’ dysfunction, discuss what the group of employees themselves could do to better understand the perspectives of each other and their boss as well as make recommendations about Moore should do now to help his team work together and manage conflicts more effectively. Charlie’s Leadership Style In assessing where Charlie Moore goes wrong, it’s important to look at his leadership style. According to the DiSC style, Charlie is a â€Å"Steady (S) Leader.† Specifically, this means Charlie operates at a methodical pace and likes leading in an orderly environment. He may readily view leading in a â€Å"fast-paced† environment as intimidating or stressful. His leadership style is collaborative in nature and he values group efforts. Charlie is a cautious leader that seldom leads by authority as he is comfortable working behind the consensus of the group as he doesn’t like making decisions alone. He is demotivated by competitive environments and changing direction abruptly. He enjoys leading in a harmonic environment with little or no confrontations or conflict. Leaders prepare the organizations for change; Charlie does not build trust nor align his people. Lack of Leadership As a leader Charlie needs to â€Å"prepare organizations for change and help them cope as they struggle through it† (Week 2, Lecture 2). The first evidence of Charlie’s failure as a leader is when he calls the group together to communicate the news about losing their major customer. The mood is somber as Charlie calls the group together to â€Å"mourn† (Sloane, The Chattanooga Ice Cream Division, HBR, p.1) and to figure out what needs to be done about it. As a leader he must exude a sense of â€Å"positive energy† (Jack Welch, Winning, p.84) to prepare his people to act and energize their best thinking to deal with this challenge. His style of (S) may not like change, but he needs to set a tone of optimism and decisiveness that says that they will come through this challenge successfully. First of all, Moore should master self-leadership for himself. Then encourage and model it for others on the team. Manz indicates that â€Å"Leaders facilitate employee self-set goals and reward effective self-leadership when it does occur. Overall, they create and nurture systems that allow teamwork and a holistic self-leadership culture to flourish† (Charles Manz, 2001, Leading Others to Lead Themselves, p. 221). I believe that Charlie and Charlie’s team would benefit from learning about their own leadership style by taking the Disc and TKI assessments and possibly creating smaller strategically paired teams within the group to come up with a foundation and vision for the direction in which the company should go as a whole. Lack of Candor Another example of where Charlie goes wrong is that he doesn’t develop an environment of trust where his people don’t hold back – even though he may not like conflict. As an example of this, Charlie has several meetings to ask his team what their thoughts are about how to compete. When you are an individual contributor, you try to have all the answers. Thats your job-to be an expert, the best at what you do, maybe even the smartest person in the room. When you are a leader, your job is to have all the questionsQuestioning, however, is never enough, following Rule 6: Leaders probe with curiosity that borders on skepticism, making sure your questions unleash debate and raise issues that get action (Welch, 2005, p. 74). Moore should first create an intentional communication strategy. His management team must understand and support a common vision with a common purpose. This requires clarity. Clarity begins with effective communication. He should make sure communication from his management team reaches all employees. The article by Ferrazzi (Harvard Business Review) indicates three specific techniques, developed from the authors research, which can help coworkers collaborate and interact more effectively. The techniques, which are based on creating trust that allows team members to speak candidly, are â€Å"dividing meetings into smaller groups, naming a candor advocate, and teaching how to give and receive feedback with a positive attitude† (Ferrazzi, 2012, Candor, Criticism, and Teamwork, p. 40). Team Dysfunctions The Chattanooga Ice Cream team is dysfunctional for several reasons. Some of those reasons include an absence of trust, avoidance, and not being accountable. Also, there is a lack of commitment amongst some managers. Moore is also looking for buy-in from all members for group decisions. There was no clear cut rule as to how decisions were going to be made. Simply put, Charles Moore failed to incorporate clear operating rules. Week Four 4 Lecture – Building High Performance Teams suggests that â€Å"when managers agree on ground rules in advance, the team is much more likely to run efficiently,† this is especially true with the Chattanooga Ice Cream team. According to Rick Johnson, Charlie could â€Å"Challenge is management team; ask for solutions, assigning both responsibility and empowerment accordingly to utilize individual skills. Ownership of ideas and initiatives builds commitment. Involving the team in creating direction and solutions through empowerment generat es commitment to the tasks necessary to meet objectives. A way to get over the major loss of a client and overshadow the â€Å"mourning†Ã‚  effect would be to challenge the management team to collectively bring in a new client or a few clients that could equal the departure of the one loss, in terms of volume. Also, Moore should create offsite team-building activities on a quarterly basis. The gatherings/outings should be used to build unification and trust in each other. New Direction for CICC Charles seems to want to be just another member of the team, an individual contributor, wanting to give his part instead of asking the explicit result-driven questions required of him in his leadership role. Welch, goes on to say, But thats the job. You want bigger solutions ask questions; healthy debate, decisions, and actions will get everyone there (p. 76). There is nowhere to go, if there is no one to lead. The dysfunctions of the team lie with the dysfunctions of the leader and no directions. Regardless of making the wrong or right decision, in regards to the CICC case, if no action is taken, then the company will fail for sure. As a Business Development Executive, I would tend to push the team to research and target other clients to fill the void left by the client lost, eliminating the somberness, creating motivation to accomplish a new goal, and strengthen the team by focusing efforts into one vision. He should run his team through assessments that could help him strategically pair individual weaknesses and strengths together, not only to complement each other going forward but to build credibility as a leader and start to build a foundation for candor, voice, and dignity going forward. Gaining new clients would most likely cost additional funds in the research and marketing and may cause little investment growth up front; however stabilizing the vision with a decision is making the correct effort to save this company under the current circumstances.