Леонид Павлов. "It specialist's tricks"
14 subscribers
77 photos
7 videos
5 files
59 links
Keep calm, no spam.
Download Telegram
Git pro tip for clear commit history and make easy revert bugged features:
1. Branch from origin/dev or any other branch you need.
2. Commit and push whatever you want.
3. Make sure you done your changes and project working fine.
4. git reset --mixed dev - resets your branch state as before first commit on it but keeps files in current state (latest commit).
5. git push -f origin - clean history and deletes "work in progress" commits in remote.
6. Structure your changes with any way git cli or any IDE to group your changes by files, directories or scopes and commit them with useful messages.
7. Now you have very clean branch state with easy possibility of reverting changes by change type and you don't need to dig in commit history to see what mean commit with message "+" or "some changes"
#pattern of the day
# Active record pattern
Pattern where record have self-contained database connection.

part = new Part()
part.name = "Sample part"
part.price = 123.45
part.save()


Or anti-pattern due to Single-responsibility principle
#pattern of the day
# State pattern

Pattern that allows manage with states of the object and events that executes before/on/after state changed and manage states routing.

Example:
var @object = new SomeObject();
var stateMachine = new StateMachine<TriggerEnum, StateEnum>(object);

stateMachine.InitState(StateEnum.NoAction);
stateMachine.Transition(TriggerEnum.TrigerSomething, StateEnum.ActionRunned, (obj, targetState) => Triggered(obj, targetState));

stateMachine.Do(TriggerEnum.TriggerSomething); // output: "Triggered on NoAction"

Console.WriteLine($"Current state: {@object.State.GetDisplay()}"); // output: Current state: ActionRunned

void Triggered(SomeObject obj, StateEnum state)
{
Console.WriteLine($"Triggered on {obj.State.GetDisplay()}");
obj.State = state;
}


See c# StateMachine that has powerful possibilities for state management: https://github.com/dotnet-state-machine/stateless
Found approach for DDD that called "aggregation root". It's looks good but only on paper (in theory) and works good with simple examples like "User, customer, shopping cart, order". On practice on every private setter you will create setter method (like in #2 of my examples). Also different methods for every system you work with. Not even talking about business logic inside database entity that violates SOLID's "single responsibility principle".
Easy localhost setup in different test environments:
IPAddress ipAddress = Dns.Resolve("localhost").AddressList[0];

#tricks #tests
Forwarded from Библиотека программиста
🛠 Всё, что нужно знать начинающему о Git: рассмотрим за 15 минут

Распределенная система контроля версий Git – популярный инструмент для координации параллельной работы и управления проектами в мире ИТ. Умение им пользоваться хотя бы на уровне основных команд необходимо даже начинающему разработчику.

🔗 Основной сайт
🔗 Зеркало