...

what we think

Blog

Keep up with our latest news, tech advancements, and articles contributed by our staff. You will discover our official announcements, exciting events, technological insight, and our staff voice.
TECH

June 19, 2024

NFC and how to use it in the Android Studio Project

NFC stands for Near Field Communication, this is a technology that has emerged as a game changer in mobile application development, providing seamless interaction between devices with just a touch. Among its many capabilities, NFC tag reading stands out as a powerful feature that allows developers to create innovative and user-friendly experiences in their Android apps. In this article, we will explore NFC in detail while also understanding how to read NFC tags in Android Studio

What is NFC?

NFC is a wireless technology that allows data to be transferred between devices over very close distances, usually just a few centimeters. This technology works on the principle of creating an electromagnetic field and communicating through it to transmit data between devices. NFC is commonly used for a variety of purposes, including mobile payments, data exchange, device connectivity, and task automation. In the mobile industry, NFC has become an important technology, especially in creating utility applications and services such as mobile payments, smart cards, and device connectivity. The strength of NFC lies in its convenience, high security, and compatibility with many different types of devices.

The convenience that NFC brings

1. Quick and easy connection:

NFC allows connection between devices simply by bringing them close together without needing to set up or search for devices in Bluetooth or Wi-Fi lists. This reduces the time and complicated steps required to connect, providing a fast and convenient experience for users. We can easily see it through Sony devices, just turn on NFC on the Sony speaker and the Sony phone, and then put them close to each other and they will connect immediately.

2. Mobile payment:

NFC has changed the way payments are made by allowing users to make financial transactions simply by touching or placing their mobile phone near an NFC reader, such as a payment terminal or machine. POS. This creates a quick, convenient, and secure payment process. The most prominent include Google Pay, Samsung Pay, and Apple Pay

3. File and data transfer:

NFC provides a convenient means of transferring files and data between devices without the need for an internet connection. Users can share photos, videos, contacts, or other files simply by touching their phone to another device.

4. Connecting IoT devices (Internet of Things):

NFC provides a simple way to connect IoT devices to each other or to the user's mobile phone. This may include configuring and connecting to devices such as lights, door locks, or other smart control devices.

5. Bluetooth and Wi-Fi connection:

NFC can also be used to initiate a Bluetooth or Wi-Fi connection between devices. Instead of having to search and connect manually, NFC can start this process automatically, reducing inconvenience for users.

How to use NFC in the Android Studio Project

Here's a basic guide to setting up the NFC tag reading in the Android Studio project:

1. Check NFC availability:
Before integrating NFC into your app, ensure that the device is capable of reading NFC and that NFC is enabled. You can do this programmatically using the NfcAdapter class.


2. Add NFC permission and declare NFC feature to Manifest:
Open your app's AndroidManifest.xml file and add the necessary permissions:

<?xml version="1.0" encoding="utf-8"?>

<manifest xmlns:android="http://schemas.android.com/apk/res/android"  xmlns:tools="http://schemas.android.com/tools">

              <uses-permission android:name="android.permission.NFC" />
              <uses-feature android:name="android.hardware.nfc" android:required="true" />


</manifest>

3. Define NFC Intent Filter:
Specify intent filters in your manifest to indicate which activities in your app should handle NFC-related actions, such as tag detection, reading, or writing.

For example:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools">
    <uses-permission android:name="android.permission.NFC" />
    <application
        android:name=".yourApplication">
        <activity
            android:name=".nfc.NfcActivity">
                <intent-filter>
                    <action android:name="android.nfc.action.NDEF_DISCOVERED" />
                    <category android:name="android.intent.category.DEFAULT" />
                </intent-filter>
        </activity>
    </application>
</manifest>


4. Handle Intent in Activity:
In your activity's onCreate() method, handle the NFC intent:

@Override
protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        if (NfcAdapter.ACTION_NDEF_DISCOVERED.equals(getIntent().getAction())) {
                  // Handle the NFC intent here
                  handleNfcIntent(getIntent());
         }
}

private void handleNfcIntent(Intent intent) {
        // Extract the NFC tag information from the intent
        Parcelable[] rawMessages = intent.getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES);
        if (rawMessages != null) {
                NdefMessage[] messages = new NdefMessage[rawMessages.length];
                for (int i = 0; i < rawMessages.length; i++) {
                       messages[i] = (NdefMessage) rawMessages[I];
                 }
                // Process the NDEF messages
               // ...
        }
}

Conclusion

In conclusion, NFC tag reading offers a myriad of benefits for Android app developers, ranging from seamless interaction and information retrieval to authentication and security. By leveraging NFC technology in your Android Studio projects, you can create immersive and intuitive experiences that delight users

[Reference- resource]
- https://developer.android.com/reference/android/nfc/NfcAdapter#summary  (Docs)
- https://www.linkedin.com/pulse/how-use-nfc-your-flutter-app-ahmed-ghaith (Image)

View More
NEWS

June 18, 2024

IVC Wins the Motivation Team Award from LMI!

We are thrilled to announce that our company has been honored with the “Motivation Team Award 2024” by Link and Motivation Inc. (LMI).

This award is a testament to our unwavering commitment to fostering a motivated, engaged, and high-performing team culture.

The “Motivation Team Award” is an annual ceremony of LMI Company that recognizes companies & departments who have made significant achievements in improving employee engagement’s status.

This recognition not only validates our efforts but also serves as motivation to continue pushing the boundaries of innovation and delivering exceptional results in employee engagement activity.

Left: Mr. Duong Nguyen - The representative receiving the award on behalf of IVC

Right: Mr. Bao Nguyen - The representative presenting the award on behalf of LMI

Our journey towards winning this award has been marked by several key initiatives such as employee engagement surveys, professional development, open communication and many other activities.

While we are proud of this achievement, we see it as a stepping-stone towards greater success. We remain committed to continuously improving our workplace culture and ensuring that our team feels motivated and supported. Together, we will continue to collaborate, and strive for excellence.

Thank you to everyone for your contribution and commitment to our company’s employee engagement activity. Your passion and dedication are what make our company a great place to work.

View More
TECH

June 12, 2024

Exploring the role of "Cushion Words" in Japanese Language

Have you ever heard of the Japanese word "cushion words"? Today, I would like to introduce some of the politest Japanese words, "cushion words".

1. What is "cushion words"? 

“Cushion words” are also called business pillow words, and by adding them as an introduction to a conversation, they have the effect of softening the impression that the words convey to the other person than if they were said directly. It is just like a “cushion” to soften the impact of words.

You can also express your feelings of “sorry” (申し訳ない) or “I may be a nuisance to the other person, but…” (もしかしたら相手としては迷惑かもしれないけれど…) in a way that shows compassion for the other person.

2.Scenes and effects where "cushion words" should be used

It is mainly used in situations where you want to make a “request”, “refusal”, or “opinion/refutation”. By using a variety of words and using them appropriately, you should be able to express your words in a way that touches the other person’s heart. It also has the effect of making it easier to convey to the other person that “You are an important person who I want to take care of”.

You can use “cushion words” when talking to customers, seniors, superiors, etc.

When making an offer or asking something, when offering something that you don’t know if the other person needs, or when you want to ask something, cushion words such as “If you don’t mind” (もしよろしければ), or “If it’s not a problem” (差し支えなければ) are used. This phrase is useful when you want to extract information from the other party during a business negotiation or meeting, or when making a proposal.

The cushion words are used not only in face-to-face communication, but also in emails and documents where it is difficult to convey nuances and feelings. This will avoid giving the impression that you are bossy or one-sided, and it will show that you are considerate.  Cushion words are essential for building trusting relations.

Here are some cases to use cushion words.

a. When asking something.

「お尋ねしてよろしいでしょうか」 (May I ask?)

「失礼ですが」 (Excuse me)

「差し支えなければ」 (If it’s not a problem)

「お教えいただきたいのですが」 (I would like to ask you to tell me.)

Ex:失礼ですが、お名前をフルネームでお聞かせいただけますでしょうか。

b. When requesting something.

「恐縮ですが」 (I’m sorry)

「ご面倒をお掛けしますが」 (I apologize for the inconvenience.)

「ご迷惑とは存じますが」 (I understand this is nuisance.)

「こちらの都合で恐れ入りますが」 (We apologize for the inconvenience.)

Ex:ご面倒をお掛けしますが、お引き受けいただけないでしょうか。

c. When you want cooperation.

「恐れ入りますが」 (Excuse me)

「お手数をおかけしますが」 (I apologize for the inconvenience)

「ご面倒をおかけします」 (I'm sorry for the inconvenience)

「お忙しいところ恐れ入りますが」 (I apologize for the inconvenience, but I'm busy)

Ex:恐れ入りますが、〇日までにメールでお返事をいただいてもよろしいでしょうか。

d. When to refuse.

「あいにく」(Unfortunately)

「残念なのですが」(Unfortunately)

「お気持ちはとてもよくわかるのですが」 (I know exactly how you feel.)

「せっかくのお申し出をいただき、大変ありがたいのですが」 (I would like to thank you very much for your request.)

「ご期待に添えず、大変申し訳ないのですが」 (I am very sorry that I did not meet your expectations.)

「私どもの力不足で、大変恐縮なのですが」 (I am very sorry that I'm lacking in ability.) 

Ex: ご希望のデザインには添えず、申し訳ございません。再度、見直しを行います。

e. When giving an opinion or counterargument.

「僭越ながら」 (Please allow me (to say something))

「おっしゃることは重々承知をしておりますが」 (I am fully aware of what you are saying.)

「余計なこととは存じますが」 (I know it's unnecessary, but...)

「私の考え過ぎかもしれませんが」 (Maybe I'm thinking too much)

Ex: おっしゃることは重々承知をしておりますが、今回はA案をご提案させていただけないでしょうか。

f. When a request cannot be met.

「せっかくお声をかけていただいたのですが」 (Thank you for taking time to contact me but)

「ぜひご期待にお応えしたかったのですが」 (I really wanted to meet your expectations but)

「身に余るお話、光栄なのですが」 (It's an honor to hear your story)

「申し上げにくいのですが」 (It's hard to tell)

Ex: 身に余るお話、光栄なのですが、今回は辞退させていただいてもよろしいでしょうか?

g. When you want something to be improved.

「細かいことを言ってしまい恐縮ですが」 (I apologize for mentioning such details)

「こちらの都合ばかりで申し訳ございませんが」 (I apologize for the inconvenience)

「説明が足りず失礼いたしました」 (I apologize for not explaining enough)

Ex: 説明が足りず失礼いたしました。決定の理由を2つ以上あげていただけると助かります。

h. When offering assistance.

「もしよろしければ」 (If you do not mind)

「私でよければ」 (If you're okay with me)

「差し支えなければ」 (If it's not a problem)

「お力になれるのであれば」 (If I can help)

Ex: もしよろしければ〇〇までご提案させていただきます。

3. Examples of NG usage of cushion words that are easy to mistake.

  • 「申し訳ございません」 (I’m sorry)

「申し訳ございません」 (I’m sorry) is a cushion word used when you can’t meet someone’s request or when you apologize. Therefore, if you use it casually when it is not needed, it will end up sounding too light in the situation where you originally wanted to use it.

NG example:

「申し訳ございませんが、お名前をお聞かせいただけますか」

「申し訳ございませんが、こちらにご記入いただいてもよろしいでしょうか」

OK example:

「申し訳ございませんが、セール品につきましては返品をご遠慮いただいております」

  • 「差し支えなければ」 (If you don’t mind)

「差し支えなければ」 (If you don’t mind) includes the meaning of “Please decline the request if it is inconvenient.” Therefore, it can only be used in situations where there is no inconvenience caused even if the other party refuses. For example, it cannot be used when you are responding to a telephone call and need to know the person’s name to be connected to the agent, so be careful.

NG example:

「差し支えなければ、 お名前を伺ってもよろしいでしょうか」

→「差し支えなければ」を「恐れ入りますが」に変更しましょう。

OK example:

「差し支えなければ資料をご自宅にお送りしましょうか」

4. Precautions when using cushion words

Cushion words are soft expressions that give a polite impression, but if used too often, they can give a dull impression and make it difficult to get the main point across.

Cushion words can be used in a variety of situations, such as emails, chats, telephone calls, and face-to-face meetings, but especially in phone calls and face-to-face situations where sentences cannot be confirmed in text, it is likely that your intentions will be difficult to convey, so avoid using cushion words frequently.

5. How to respond to 「差し支えなけれ」 (If you don’t mind)

So far, we have looked at the expressions 「差し支えなけれ」 (If you don’t mind) used when requesting someone to do something, but there may be times when the other makes a request “If you don’t mind” to us. When accepting a request, a response such as 「承知しました」 (I understand) or 「かしこまりました」 (I understand) is appropriate.

Also, as mentioned above, 「差し支えなけれ」 (If you don’t mind) is an expression that leaves the decision on whether or not to accept the request to you, so of course you can decline it.

When you say “No”, be sure to show that you are sorry.

For example, if you can respond with something like 「大変申し訳ないですが、〇〇があるため、行うことが難しい状況です。お役に立てず恐縮でございます」 (I’m very sorry, but due to 〇〇, I’m unable to help you, I’m sorry that I can’t help you.)

This will leave a good impression.

6. Use cushion words appropriately to facilitate communication.

Cushion words are used in a variety of business situations to show consideration for others and facilitate communication.

It’s good idea to understand multiple phrases and appropriate situations, as they will be useful in situations where you need to convey something that is difficult to convey, such as when declining a request from someone or making a counterargument.

Make sure to use cushion words appropriately depending on the situation and maintain smooth communication and good relationships.

Reference Image and Document Source:

  • https://www.pexels.com/
  • https://go.chatwork.com/
  • https://allabout.co.jp/
View More
NEWS

June 12, 2024

Celebrating International Children's Day at IVC!

At IVC, we believe that children are the future; their well-being and happiness are paramount to creating a better world tomorrow.

As we celebrate International Children's Day, we take this opportunity to honor the joy, innocence, and potential of all IVC children!

 

 

We understand that the smiles of children are great joy and motivation every day for IVC employees, who have little angels in their family.

Hence, the company always places great emphasis on caring and taking care of IVC's children and our commitment to children is shown very specifically in the company's welfare packages. Especially, on the 1st of June every year - International Children's Day - is the occasion that the company and Union coordinate to give lovely gifts and send best wishes to IVC children.

We believe that by investing in the well-being of children today, we are building a better world tomorrow.

 

 

Thank you for joining us in this celebration.

Children are the bright stars of tomorrow, we are so proud of each and every one of them. May our children's day be filled with fun, love, and wonderful surprises.

Let’s work together to make every day a day that children can smile about.

Happy International Children's Day!

View More
ARTICLE

June 11, 2024

Life's Turning Points and Embracing Change

Life is full of twists, unexpected turns, and surprising moments of clarity. At the heart of this journey lies what we often refer to as "turning points" — those pivotal moments that change our lives. Sometimes it comes sweetly and excitedly, sometimes it's unexpected changes that weren't planned, or sometimes it's mental shocks that can make people collapse. These turning points challenge us, shape us, and ultimately define who we are and who we become.

In the midst of life's upheavals, it's natural to feel a mix of emotions: fear, uncertainty, excitement, and anticipation. Yet, it's how we respond to these turning points that truly matters. Do we shrink back in fear, clinging to the familiar, or do we embrace the unknown, stepping forward with courage and resilience?

How to handle life's turning points with grace and wisdom?

Embrace change: Change is inevitable. It's the only constant in life. Instead of resisting it, embrace it. Recognize that change often brings growth, new opportunities, and fresh perspectives. Embracing change allows us to adapt, evolve, and thrive in the face of uncertainty.

Stay flexible: Rigidity breeds resistance. Stay flexible and open-minded in your approach to life's turning points. Be willing to pivot, adjust your plans, and explore new possibilities. Flexibility enables us to flow with the currents of change rather than against them.

Trust yourself: In moments of uncertainty, trust yourself. Trust your intuition, inner wisdom and trust your judgment and decision-making abilities. Remember that you have the strength, resilience, and resourcefulness to navigate life's challenges. Trust that you have what it takes to overcome the storms and emerge stronger on the other side.

Seek support: You don't have to navigate life's turning points alone. Reach out to friends, family, mentors, or anyone that you trust for guidance and encouragement. Surround yourself with people who uplift and inspire you, who believe in your potential, and who offer a listening ear and a shoulder to lean on when needed.

Embrace growth: Every turning point is an opportunity for growth and self-discovery. Lean into the discomfort, lean into the unknown, and embrace the journey of personal and spiritual growth. Allow yourself to learn, evolve, and become the best version of yourself through life's twists and turns.

Find meaning: In the midst of chaos and uncertainty, seek meaning and purpose. Reflect on the lessons learned, the wisdom gained, and the deeper truths revealed through life's turning points. Find meaning in the challenges you face, the obstacles you overcome, and the journey you're on.

Practice gratitude: Gratitude is a powerful antidote to fear and uncertainty. Cultivate gratitude even when life challenges you. In challenges, there are always hidden opportunities for optimistic people. Take time each day to acknowledge your blessings, embrace the little good things around you, and express gratitude for the journey, with all its twists and turns.

Life's turning points may be unpredictable and at times challenging, but they also hold the promise of growth, transformation, and new beginnings. By embracing change, staying flexible, trusting yourself, seeking support, embracing growth, finding meaning, and practicing gratitude, you can navigate life's turning points with grace, resilience, and wisdom. Embrace the journey, embrace the unknown, and trust that the best is yet to come.

Image source: freepik.com

View More
BUSINESS

June 5, 2024

Think Like a Startup, Act Like a Leader: Embracing Agile

In today's rapidly changing business landscape, adaptability is key. The agile mindset, a way of thinking that prioritizes flexibility, customer value, and continuous improvement, empowers businesses to thrive amidst uncertainty.

What is the Agile Mindset?

Born in the software development world, the agile mindset isn't limited to tech. It's a versatile approach applicable to any industry. Here's the essence:

  • Adaptability: Embracing the unknown and pivoting strategies as needed.
  • Customer Focus: Putting the customer's needs front and center, crafting solutions that truly deliver value.
  • Collaboration: Working together as a team, breaking down silos to foster innovation.
  • Experimentation: Treating work as iterative cycles of learning, adjusting, and improving.
  • Continuous Learning: Regularly reflecting on performance, seeking feedback, and constantly growing.

 

 

Why the Agile Mindset Matters?

The agile mindset offers numerous benefits:

    • Faster Innovation: Agile teams are nimble, quickly adapting to changing customer needs and market trends.
    • Improved Quality: Through iterative development and testing, agile methods often lead to higher quality products or services.
    • Increased Resilience: Agile organizations are better equipped to handle disruptions and setbacks.
    • Enhanced Morale: Agile teams feel empowered, engaged, and invested in their work.

 

Developing an Agile Mindset: Tips for Daily Practice

Here are simple ways to cultivate an agile mindset in your daily work:

 

 

  • Embrace Feedback: Actively seek and openly receive feedback from colleagues and customers.
  • Break Down Tasks: Divide large projects into smaller, more manageable tasks to enable quicker progress and frequent feedback.
  • Reflect and Learn: Regularly set aside time for reflection to assess what's working, what isn't, and how to improve

 

 

Conclusion:

In an era of constant change, the agile mindset is not just an advantage – it's a necessity. By embracing flexibility, customer focus, collaboration, experimentation, and continuous learning, businesses can not only survive but thrive in the face of any challenge.

Contact us today to learn more about how we can help your organization thrive in the dynamic business world.

 

Reference Images:

View More
NEWS

June 5, 2024

Announcement of Signing of MoU between ISB Vietnam Co., Ltd. and Kirirom Institute of Technology

ISB Vietnam Co., Ltd. (IVC) is pleased to announce that we have signed a Memorandum of Understanding (MoU) with Kirirom Institute of Technology (KIT Cambodia) to strengthen cooperation between the two organizations. The MoU was signed by Mr. Onogawa Yasuto, General Director of IVC, and Dr. Masamu Kamaga, President of KIT Cambodia, on May 28, 2024.

The primary objective of the MoU is to advance academic and marketing research in the field of human resource development. Both parties intend to facilitate exchange visits to strengthen partnerships through this collaborative effort.

Moreover, it also mentions facilitating student, staff, and faculty exchanges, collaborating on joint projects and activities, and exploring other mutual interests.

KIT Cambodia greatly values the practical experiences and accomplishments of IVC over the last 20 years. Through its dedication, KIT Cambodia will also focus on training and selecting high-quality human resources to meet IVC's expectations for accessing international markets.

In line with this, IVC will suggest projects that align with the skills of KIT Cambodia students to engage them in real-life projects. IVC also sees this as an opportunity for IVC staff and KIT Cambodia's students to learn from each other, sharing expertise and cultural insights.

The signing of the MoU is an important milestone that will result in enhanced cooperation opportunities in the future. Both sides are committed to working together to achieve common goals and support each other throughout the process.

View More
ARTICLE

May 15, 2024

How To Get Through Challenging Times

In life and work, things don't always turn out the way we expect. The road to success is not always a straight line, it's filled with twists, turns, and obstacles. There will likely be times in life when stress levels rise and everything seems overwhelming. However, challenges and hardships are inevitable, and the real concern is not about the difficulties themselves, but rather the mindset and attitude we bring when facing them. This blog post will explore some ways to help you through tough times and find resilience in the face of adversity.

  • Shift Your Mindset

Your mindset shapes your actions and how you respond to life’s challenges. You will easily find joy in everyday experiences when you have a positive mindset. If you don't see something as a problem, it just becomes a simple thing. Simplifying life and simplifying problems is the foundation for optimism and positive thinking. Never allow yourself to get bogged down by negativity, because a single negative mindset can completely change you. As you shift your perspective to a more optimistic view, you'll begin to see the world in a new light, and problems that once seemed overwhelming will become manageable.

  • Don't Compare Yourself to Others

When facing challenges, it’s easy to fall into the trap of comparing yourself to others. However, this kind of comparison won't provide you with any meaningful answers because they are not you. Each person is a unique individual from the moment they're born and everyone has their challenges, advantages, and shortcomings. Comparing your journey to someone else’s can lead to negative thoughts and unnecessary stress. Instead, focus on your progress, comparing where you are today to where you were yesterday to see how you've grown. Remove these comparisons and negative thoughts from your mind, and focus on finding solutions to the problems you're facing.

  • Seek Support

Don't hesitate to reach out for support during tough times. Whether it's friends, family, or colleagues, having someone to talk to and share your thoughts with, can provide you comfort, guidance, and perspective. Remember you're not alone in facing challenges, while they may not always give you the perfect solution, they will understand what you're going through and will help you regain your emotional balance.

  • Embrace and Stay Resilient

The truth is, that we are much more resilient than we often realize. No matter what you face today, just keep moving forward and give yourself some credit for your perseverance, give yourself hope each day, and try not to worry about tomorrow or dwell on the past. Focus on making the most of today, this moment, and imagine how the best it can be. You will find life becomes a little brighter and one day when you look back, you will realize just how strong you are.

Life isn't a straight path paved with roses, but rather a rocky road with many forks. It's only by daring to cross this path that you can reach the threshold of success. Every challenge, no matter how tough, always has its solution. Never be pessimistic or depressed because life is not a race, it's a long journey that we overcome step by step and contemplate the meaning as we go. So, take a deep breath and keep going. With determination and the right mindset, you'll find that even the roughest roads can lead to remarkable places.

 

View More
ARTICLE

May 6, 2024

CHANGE TO BE BETTER

The ability to adapt to change is essential for proactively responding to life's various situations. While we may be accustomed to our daily routines and hesitant to embrace change, the truth is that our lives are constantly evolving.

Adaptation entails effectively adjusting to environmental and circumstantial changes in order to align with current trends. It is a soft skill that can be cultivated through determination and a positive outlook on life.

So, how can we adapt well? Here are some of my suggestions:

-          Embrace a mindset of considering different scenarios

Cultivate the habit of asking "what if" questions before commencing any task. This approach isn't about being negative or pessimistic; rather, it helps us prepare and develop a forward-thinking perspective. By envisioning potential challenges, we can identify solutions and be better equipped to handle arising problems.

-          Actively seek out experiences and new knowledge

Break away from routine and embrace learning opportunities. By proactively engaging with novel ideas and experiences, even in small ways, you become a trailblazer, open to embracing new things. This continual growth enhances your knowledge and understanding, enabling you to absorb and comprehend fresh concepts.

-          View failures as valuable lessons

When embracing change, it's possible to encounter setbacks. Instead of feeling embarrassed or disheartened, consider failures as practical lessons that can guide you to avoid future mistakes. Embrace them as opportunities to improve, complete tasks more effectively, and step out of your comfort zone. Every failure can provide valuable insights and contribute to your personal growth.

***These are just some suggestions to help you adapt to changes in both your work and personal life. Remember, transforming challenges into opportunities requires ongoing effort and a determination to overcome obstacles. By persistently striving to overcome difficulties and embrace change, you can navigate life's transitions with greater success.

 

View More
TECH

April 25, 2024

Dependency Injection Overview: Using Dependency Injection in ASP.NET Core

In the world of software development, Dependency Injection (DI) stands as a fundamental concept, often hailed as a cornerstone of good design and modular architecture. But, for many developers, especially those newer to the field, the term can evoke confusion or difficult to understand. I hope that the blog will help you understand DI better.

1. Understanding Dependency Injection

At its core, Dependency Injection is a design pattern used to manage dependencies between different components or modules within a software system. It can be understood simply as follows:
  • Modules do not communicate directly with each other, but through an interface. The low-level module will implement the interface, the high-level module will call the low-level module through the interface.
  • For example: To communicate with customer service, we have the ICustomerService interface, the low-level modules are CustomerService. The high-level module CustomerController will only use the ICustomerService interface.
  • Initialization of low-level modules will be performed by DI Container. For example: In the CustomerController, we will not initialize ICustomerService service = new CustomerService (), this will be done by DI Container. The CustomerController will not know anything about the class CustomerService
  • Which Module is attached to which interface will be configured in the class Program.cs

2. The Three Types of Dependency Injection

Dependency Injection can be implemented in three main ways: Constructor Injection, Setter Injection, and Interface Injection.
  • Constructor Injection: In this approach, dependencies are provided through a class's constructor. This ensures that all required dependencies are available when an object is instantiated, promoting immutability and simplifying testing.
  • Setter Injection: Also known as property injection, Setter Injection involves providing dependencies through setter methods. While not as preferred as Constructor Injection due to the potential for objects to be in an invalid state, Setter Injection can be useful for optional dependencies.
  • Interface Injection: This approach is less common and involves providing dependencies through an interface that the client class implements. However, this method can introduce tight coupling between the client class and the injector, making it less flexible compared to Constructor Injection.
Among the three types of Inject, Constructor Injection method is very popular because of its flexibility, ease of building DI libraries...

3. Advantages and disadvantages of Dependency Injection

Advantage

  • Reduce adhesion between modules
  • Code is easy to maintain, easy to replace modules
  • Very easy to test and write Unit Test

Disadvantages

  • The concept of DI is quite difficult to understand new developers will have difficulty learning it
  • Objects are completely initialized from the beginning, which can reduce performance Increases code complexity

4. Using DI in .NET CORE

Use Dependency Injection through these steps:
  1. Use an interface or base class to abstract implementation dependencies.
  2. Register the dependency in the service container. ASP.NET Core allows us to register our application services with the IoC container, in the Program.cs class use IServiceCollection to register application services
  3. Include the service in the constructor of the class in which it is used. The framework will create an instance of the dependency and remove it when it is no longer needed.
Example: The ICustomerService interface defines the SendMessage method
public interface ICustomerService {
    void SendMessage(string message);
}
We have the CustomerAService implement ICustomerService1
public class CustomerAService : ICustomerService {
    public void SendMessage(string message)
    {
        Console.WriteLine($"CustomerAService.SendMessage Message: {message}");
    }
}
The AddScoped method registers the service with scoped lifetime, the lifetime of a singleton request
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddScoped<ICustomerAService, CustomerAService>();
 
var app = builder.Build();
There are 3 lifecycle levels: addTransient, addScoped, addSingleton.
  • Transient: Instance is initialized each time a service is created
  • Scoped: Instance is initialized per scope. (Scope here is each request sent to the application). In the same scope, the service will be reused.
  • Singleton: The service instance is created uniquely at application launch and is used everywhere
ICustomerService is required and used to call the SendMesasge method
public class CustomerController : PageModel {
    private readonly ICustomerService _customerService;
    public Index2Model(ICustomerService customerService) {
        _customerService = customerService;
    }
    public void OnSendMesasge() {
        _customerService.SendMessage("Send message");
    }
}
By using the DI pattern, the controller will: Not use CustomerAService, only use the ICustomerService interface. That makes it easy to change the Controller's implementation without modifying the Controller.

View More
1 2 3 4 5 19
Let's talk about your project! CONTACT US


At ISB Vietnam, we believe in making a positive difference to our clients through our software development outsourcing services.

As a prestigious offshore software development company in Vietnam, we've been providing top-notch solutions to numerous clients for over two decades since 2003.

Add the attachment
*Up to 10MB
...