Cyril  Parisian

Cyril Parisian


Coupling in C-Sharp

In the programming world, after the advent of object-oriented programming, classes and objects came into existence and became the most preferred type of programming. Though the programming language would differ (Java, C#, etc…,) the underlying concept always remained as object-oriented programming.

Here, classes, objects, methods play a crucial role in setting up the structure of the code. Initially, the three-tier architecture pattern was followed and then later moved on to MVC. However, in both these patterns, classes were created based on roles and responsibilities. Say, for example, a class could be created to do DB operations, similarly one for the business layer, one for external calls or any specific functions, and so on.

There will be a necessity for the business layer to connect to the database layer, and similarly the presentation layer to interact with the business layer. In these cases, the classes have to communicate with each other. Ultimately, the object of the classes will be used to call the exposed methods.

How the classes are connected is referred to as Coupling. There are two ways of coupling in C#. Let’s see in detail about them in this blog along with a brief understanding of what is coupling.

Table of contents

  1. What is Coupling?
  2. Tightly Coupled
  3. Loosely Coupled?
  4. Conclusion

What is Coupling?

Here is the classic definition of coupling — It is the degree to which the software components depend on each other.

Coupling in C## describes the relationship between modules in C#, how the classes and objects are connected, and also how dependent they are on each other. This also describes the flexibility and reusability part of the code.

A coupling as such is needed for successful communication between modules. But, how the modules are coupled determine the standard of the code. Let’s see in detail the two types of coupling now.

Tightly Coupled

Think of it this way — your fingers are tightly coupled with the hand, which makes it hard to change the position of the fingers and their location. This means that changing the position of fingers is close to impossible and requires redesigning of the hand. This is an example of being tightly coupled.

The classes and objects are very much interdependent, so it becomes difficult to reuse the code. When there are many dependent components, then it becomes difficult to maintain the code for enhancements.

Let us take an example, to understand things better. Go to ParTech to see this article and the example.

In the example code on the ParTech website, we have a Program class from where the code begins to execute. Here the program class has a main method and it holds the code to create an object for filereader which expects a file name. And inside the filereader class, there are two methods, one to read the data from the file and another one to save the data to a file. The save method creates an object for another class which is then used to save the data to a different file.

Since the two classes are concrete or tightly coupled, and as they know the entire implementation of the class, it is difficult to make additional changes. This is simply because the changes have to be done at a lot of places. Imagine a similar kind of coupling in a much larger application. It will be extremely tricky to maintain and support the code.

#coupling #csharp #c

What is GEEK

Buddha Community

 Coupling in C-Sharp
Tamale  Moses

Tamale Moses


How to Run C/C++ in Sublime Text?

C and C++ are the most powerful programming language in the world. Most of the super fast and complex libraries and algorithms are written in C or C++. Most powerful Kernel programs are also written in C. So, there is no way to skip it.

In programming competitions, most programmers prefer to write code in C or C++. Tourist is considered the worlds top programming contestant of all ages who write code in C++.

During programming competitions, programmers prefer to use a lightweight editor to focus on coding and algorithm designing. VimSublime Text, and Notepad++ are the most common editors for us. Apart from the competition, many software developers and professionals love to use Sublime Text just because of its flexibility.

I have discussed the steps we need to complete in this blog post before running a C/C++ code in Sublime Text. We will take the inputs from an input file and print outputs to an output file without using freopen file related functions in C/C++.

#cpp #c #c-programming #sublimetext #c++ #c/c++

Dicey Issues in C/C++

If you are familiar with C/C++then you must have come across some unusual things and if you haven’t, then you are about to. The below codes are checked twice before adding, so feel free to share this article with your friends. The following displays some of the issues:

  1. Using multiple variables in the print function
  2. Comparing Signed integer with unsigned integer
  3. Putting a semicolon at the end of the loop statement
  4. C preprocessor doesn’t need a semicolon
  5. Size of the string matters
  6. Macros and equations aren’t good friends
  7. Never compare Floating data type with double data type
  8. Arrays have a boundary
  9. Character constants are different from string literals
  10. Difference between single(=) and double(==) equal signs.

The below code generates no error since a print function can take any number of inputs but creates a mismatch with the variables. The print function is used to display characters, strings, integers, float, octal, and hexadecimal values onto the output screen. The format specifier is used to display the value of a variable.

  1. %d indicates Integer Format Specifier
  2. %f indicates Float Format Specifier
  3. %c indicates Character Format Specifier
  4. %s indicates String Format Specifier
  5. %u indicates Unsigned Integer Format Specifier
  6. %ld indicates Long Int Format Specifier

Image for post

A signed integer is a 32-bit datum that encodes an integer in the range [-2147483648 to 2147483647]. An unsigned integer is a 32-bit datum that encodes a non-negative integer in the range [0 to 4294967295]. The signed integer is represented in twos-complement notation. In the below code the signed integer will be converted to the maximum unsigned integer then compared with the unsigned integer.

Image for post

#problems-with-c #dicey-issues-in-c #c-programming #c++ #c #cplusplus

최  호민

최 호민


C. C++. C#. 차이점 알려드림. 5분 순삭. Explain C.C++.C#. Like I'm Five

업데이트가 늦었습니다 ㅠㅠㅠ (결혼 축하해주신 분들 너무 고맙습니다! ;))
오늘도 코린이. 코알못을 위한 영상을 들고 왔어요!
아시죠? C는 C++.C# 줄인말이 아니라는거? (껄껄껄)
또 궁금한것 있으시면 언제든 댓글로 남겨주세요~

#c++ #c #c-sharp

Shaylee  Lemke

Shaylee Lemke


Learn how to perform CRUD operations using C Sharp

In this Quick Start post, I’ll show how to set up connections between C# and MongoDB. Then I’ll walk through the database Create, Read, Update, and Delete (CRUD) operations. As you already know, C# is a general-purpose language and MongoDB is a general-purpose data platform. Together, C# and MongoDB are a powerful combination.

#c #c# #c++ #programming-c

Ari  Bogisich

Ari Bogisich


Using isdigit() in C/C++

In this article, we’ll take a look at using the isdigit() function in C/C++. This is a very simple way to check if any value is a digit or not. Let’s look at how to use this function, using some simple examples.

#c programming #c++ #c #c#