Tuesday, April 14, 2020

SwiftInject

Swinject is a lightweight dependency injection framework for Swift.

Dependency injection (DI) is a software design pattern that implements Inversion of Control (IoC) for resolving dependencies. In the pattern, Swinject helps your app split into loosely-coupled components, which can be developed, tested and maintained more easily. Swinject is powered by the Swift generic type system and first class functions to define dependencies of your app simply and fluently.

Why Dependency Injection?
Dependency Injection relies on a principle called Inversion of Control. The main idea is that a piece of code that requires some dependencies won’t create them for itself, rather the control over providing these dependencies is deferred to some higher abstraction. These dependencies are typically passed into an object’s initializer. This is the opposite approach — an inverted approach — to the typical cascade of object creation: Object A creating Object B, creating Object C, and so on.

From a practical perspective, the main benefit of Inversion of Control is that code changes remain isolated. A Dependency Injection Container supports the Inversion of Control principal by providing an object that knows how to provide the dependencies for an object. All you need to do is ask the container for the object you need, and voilĂ … it’s ready!

references:
https://github.com/Swinject/Swinject

Tuesday, April 7, 2020

Installing MongoDB community Editiion

After Mac OS catalina update, the mongo db stopped working. now trying to reinstall, the steps are below

This time attempting to install community edition. In machine, the Xcode, So below steps really were the ones that had to be followed

brew tap mongodb/brew
brew install mongodb-community@4.2

In addition to the binaries, the install creates:

the configuration file (/usr/local/etc/mongod.conf)
the log directory path (/usr/local/var/log/mongodb)
the data directory path (/usr/local/var/mongodb)


Run MongoDB Community Edition
Follow these steps to run MongoDB Community Edition. These instructions assume that you are using the default settings.

You can run MongoDB as a macOS service using brew, or you can run MongoDB manually as a background process. It is recommended to run MongoDB as a macOS service, as doing so sets the correct system ulimit values automatically (see ulimit settings for more information).

To run MongoDB (i.e. the mongod process) as a macOS service, issue the following:

brew services start mongodb-community@4.2
To run MongoDB manually as a background process, issue the following:

mongod --config /usr/local/etc/mongod.conf --fork
Both methods use the /usr/local/etc/mongod.conf file created during the install. You can add your own MongoDB configuration options to this file as well.

To verify that MongoDB is running, search for mongod in your running processes:

ps aux | grep -v grep | grep mongod
You can also view the log file to see the current status of your mongod process: /usr/local/var/log/mongodb/mongo.log.

Connect and Use MongoDB
To begin using MongoDB, connect a mongo shell to the running instance. From a new terminal, issue the following:

mongo


https://docs.mongodb.com/manual/tutorial/install-mongodb-on-os-x/