Prezentace Tomáše Vichty z Profinitu na konferenci MS Fest 18.3. v Brně.
SOLID je léty ověřená sada 5ti základních pravidel pro návrh objektového kódu, která by měl znát a používat každý vývojář pracující v objektovém jazyku.
V Profinitu dbáme na důsledné používání těchto pravidel jak při vývoji nového software, tak při redesignu existujících řešení. Díky tomu dokážeme dělat lepší systémy/aplikace s menšími náklady, které přinášejí užitek svým uživatelům, a IT správci ani vývojáři se jich nebojí.
[EN] This is in Czech
[CZ] Jednotkové testy snadno a rychle dík využití těch správných nástrojů - Mockito, DbUnit, Groovy aj. Opomíjené přínosy testů. Bonus: TDD a mutační testování.
Ukážeme si, že Doctrine není jenom ORMko a kdy jít o vrstvu níž. Jak DQL naučit věci, které v základu neumí, ale vaše databáze ano. A pár dalších tipů, jak nemít z databáze úplně hloupé úložiště.
[EN] This is in Czech
[CZ] Jednotkové testy snadno a rychle dík využití těch správných nástrojů - Mockito, DbUnit, Groovy aj. Opomíjené přínosy testů. Bonus: TDD a mutační testování.
Ukážeme si, že Doctrine není jenom ORMko a kdy jít o vrstvu níž. Jak DQL naučit věci, které v základu neumí, ale vaše databáze ano. A pár dalších tipů, jak nemít z databáze úplně hloupé úložiště.
Reference data is something we often encounter in our projects. In our experience, it is often underestimated and does not get enough attention. In the webinar, we want to make you aware of some interesting aspects of ‘reference data’ such as how it relates to MDM, which it’s often mixed with.
Cloud in examples—(how to) benefit from modern technologies in the cloudProfinit
The world of cloud services is enormous, rapidly growing, and changing fast, so it can be challenging to choose the right service and architecture to meet your needs.
To help you better navigate the options and inspire you, we’ve made this webinar describing two practical ways to use cloud services and benefit from the out-of-the-box features and infrastructure the cloud provides.
Building big data pipelines—lessons learnedProfinit
What is the power of business departments? What is missing in communication between layers responsible for building big data solutions? What mistakes can happen when IT departments are too proactive in creating solutions for big data?
Understand your data dependencies – Key enabler to efficient modernisation Profinit
Modernising any system is a comprehensive task. Every step has to be estimated, appropriately planned, then carefully executed and verified. Data with its dependencies are the common denominator in almost every case and crucial in understanding the whole initiative.
In this webinar, experts from Profinit and Manta will present their approach to resolving data-related challenges while modernising software systems using Profinit Modernisation Framework in collaboration with Manta tools.
Knowing your clients well and knowing when they need financial support is a key part of a bank’s success in lending. But it is challenging to gather and process information about your customers to know them all entirely. Our senior consultant Lukáš Dvořák will show you how to use data to drive your lending business and improve the conversion rate of loan offers.
What to do when a system stops providing the value that your business needs and an immediate change is necessary? Replacing such a system is usually the first idea that comes to mind. However, is it the only and the best approach you should consider? Not necessarily!
Automating Data Lakes, Data Warehouses and Data StoresProfinit
This webinar discusses automating data warehouses, lakes, and stores. It introduces the speaker, Petr Hájek, and his experience. Profinit, the company hosting the webinar, is introduced along with their competencies and certifications. The webinar then covers challenges with traditional manual approaches and how automation can help through frameworks, templates, and metadata to generate scripts. A case study of automating a data warehouse for a gambling regulator is presented, highlighting benefits like reduced time and costs. Automation is argued to make solutions more transparent, agile, and organized compared to traditional approaches.
When the complexity of all the data in your business exceeds a certain level, it is time to make a sound decision and start taking steps towards professional and systematic data governance and clear data architecture. This step is what we call “data landscape mapping”. At the end of this initial process, you will get something like a Google map of all the data in your company, visualised from different angles and dimensions.
What to do when a system stops providing the value that your business needs and an immediate change is necessary? Replacing such a system is usually the first idea that comes to mind. However, is it the only and the best approach you should consider? Not necessarily!
Profinit Webinar: Benefits of Software Systems Modernization over their Repla...Profinit
Nowadays, many companies are facing challenges linked to their core systems. The systems lack support for the new business models, do not fit-for-purpose anymore or provide poor UX. In general, they are slow to change, risky and costly to enhance and maintain. What would you do, when a system does not provide the value that your business needs? Replacing such a system is usually the first idea that comes to mind. However, is it the only approach you should consider?
In our webinar, Michal Petřík (Profinit's Head of Software Development) will discuss a different approach that is often faster, safer and better suited for many businesses.
Dominik Matula presented Instalment Detector, a tool that reveals clients' payment behaviors from transactional banking data through advanced machine learning techniques. It aims to improve risk scoring, maximize profit, and help clients save through detecting hidden loan payments. The tool engineers complex features from relationships between transactions and uses Bayesian networks to achieve a 100% boost in detecting instalment payments compared to conventional methods. The tool provides interpretable results while adapting to market changes and can be applied to other financial fields.
Reference data is something we often encounter in our projects. In our experience, it is often underestimated and does not get enough attention. In the webinar, we want to make you aware of some interesting aspects of ‘reference data’ such as how it relates to MDM, which it’s often mixed with.
Cloud in examples—(how to) benefit from modern technologies in the cloudProfinit
The world of cloud services is enormous, rapidly growing, and changing fast, so it can be challenging to choose the right service and architecture to meet your needs.
To help you better navigate the options and inspire you, we’ve made this webinar describing two practical ways to use cloud services and benefit from the out-of-the-box features and infrastructure the cloud provides.
Building big data pipelines—lessons learnedProfinit
What is the power of business departments? What is missing in communication between layers responsible for building big data solutions? What mistakes can happen when IT departments are too proactive in creating solutions for big data?
Understand your data dependencies – Key enabler to efficient modernisation Profinit
Modernising any system is a comprehensive task. Every step has to be estimated, appropriately planned, then carefully executed and verified. Data with its dependencies are the common denominator in almost every case and crucial in understanding the whole initiative.
In this webinar, experts from Profinit and Manta will present their approach to resolving data-related challenges while modernising software systems using Profinit Modernisation Framework in collaboration with Manta tools.
Knowing your clients well and knowing when they need financial support is a key part of a bank’s success in lending. But it is challenging to gather and process information about your customers to know them all entirely. Our senior consultant Lukáš Dvořák will show you how to use data to drive your lending business and improve the conversion rate of loan offers.
What to do when a system stops providing the value that your business needs and an immediate change is necessary? Replacing such a system is usually the first idea that comes to mind. However, is it the only and the best approach you should consider? Not necessarily!
Automating Data Lakes, Data Warehouses and Data StoresProfinit
This webinar discusses automating data warehouses, lakes, and stores. It introduces the speaker, Petr Hájek, and his experience. Profinit, the company hosting the webinar, is introduced along with their competencies and certifications. The webinar then covers challenges with traditional manual approaches and how automation can help through frameworks, templates, and metadata to generate scripts. A case study of automating a data warehouse for a gambling regulator is presented, highlighting benefits like reduced time and costs. Automation is argued to make solutions more transparent, agile, and organized compared to traditional approaches.
When the complexity of all the data in your business exceeds a certain level, it is time to make a sound decision and start taking steps towards professional and systematic data governance and clear data architecture. This step is what we call “data landscape mapping”. At the end of this initial process, you will get something like a Google map of all the data in your company, visualised from different angles and dimensions.
What to do when a system stops providing the value that your business needs and an immediate change is necessary? Replacing such a system is usually the first idea that comes to mind. However, is it the only and the best approach you should consider? Not necessarily!
Profinit Webinar: Benefits of Software Systems Modernization over their Repla...Profinit
Nowadays, many companies are facing challenges linked to their core systems. The systems lack support for the new business models, do not fit-for-purpose anymore or provide poor UX. In general, they are slow to change, risky and costly to enhance and maintain. What would you do, when a system does not provide the value that your business needs? Replacing such a system is usually the first idea that comes to mind. However, is it the only approach you should consider?
In our webinar, Michal Petřík (Profinit's Head of Software Development) will discuss a different approach that is often faster, safer and better suited for many businesses.
Dominik Matula presented Instalment Detector, a tool that reveals clients' payment behaviors from transactional banking data through advanced machine learning techniques. It aims to improve risk scoring, maximize profit, and help clients save through detecting hidden loan payments. The tool engineers complex features from relationships between transactions and uses Bayesian networks to achieve a 100% boost in detecting instalment payments compared to conventional methods. The tool provides interpretable results while adapting to market changes and can be applied to other financial fields.
3. 3
Proč SOLID?
› Snadnější a bezpečnější rozšiřitelnost
› Přehlednost
› Znovupoužívání kódu
– Jednotné chování aplikace
› Lépe testovatelný kód
– unit testy i mocky pro testovací prostředí
› Méně bugů
4. 4
Single Responsibility Principle
› 1 třída má 1 zodpovědnost
› Není dobré jít do extrému (třídy s 1 řádkem kódu)
› Ale když váhám, tak kód raději hned rozdělím na více tříd
SINGLE RESPONSIBILITY PRINCIPLE
Just Because You Can, Doesn't Mean You Should
5. 5
Single Responsibility Principle
class BigClass
{
public void Load() { }
public void Compute() { }
}
class Loader
{
public void Load() { }
}
class Calculator
{
public void Compute() {
}
}
6. 6
Dependency Inversion Principle
› Třída má záviset na abstrakci
– Interface, base (často abstract) class
› Tzn. implementaci dodáme třídě zvenku
– Constructor, Property, Method Injection
› Souvisí s Inversion of Control/Dependency Injection
1
2
3
1
2
3
7. 7
Dependency Inversion Principle – příklad
class BetterComputeController
{
private readonly ICalculator _calc;
public IMailer Mailer { get; set; }
public BetterComputeController(ICalculator calc) { _calc = calc; }
public void Process(object model)
{
_calc.Compute();
Mailer?.Send("computed successfully");
}
}
class BadComputeController
{
public void Process(object model)
{
new Calculator().Compute();
if (true)
new Mailer().Send("computed successfully");
}
}
8. 8
Open-closed Principle
› Nová funkcionalita se přidává novým kódem, nikoli modifikací
starého
› Open
– Nová funkcionalita = nová třída
• Děděním
• Novou implementací stávajících interfaces
› Closed
– Nesahám do stávajících tříd
› Netýká se bugfixingu, refaktoringu, většinou ani změn
10. 10
Liskov substitution Principle
› Subclass se chová navenek stejně jako base class
› Rozšiřuje Open-closed princip
› Metody v Subclass
– Nevyhazovat žádné nové výjimky (kromě poděděných), protože
s nimi klient nemusí počítat.
– Nesmí vyžadovat větší omezení na vstupní argumenty
– "Postconditions cannot be weakened in a subtype."
› Neměnit vnější stav, pokud to klient nečeká
› Typický příklad
– čtverec vs. obdélník a metody SetWidth(), SetHeight(), ComputeArea()
12. 12
Interface Segregation Principle
› Každá funkcionalita má svůj, co nejmenší interface
› Klient: Používám interface/třídu
– jsou tam jen metody, které potřebuji
› Implementuji interface
– ten by neměl mít metody, které v mojí implementaci nemají smysl
– tj. nepotřebuji NotSupportedException jako jediný řádek metody
› Souvisí se Single Responsibility z pohledu konzumenta (klienta)
– Ale není to to samé, je legitimní dělit 1 responsibility do více interfaces
14. 14
Interface Segregation Principle – příklad
public struct Int32 : IComparable, IFormattable, IConvertible
public abstract class Controller : ControllerBase,
IActionFilter, IAuthorizationFilter, IDisposable,
IExceptionFilter, IResultFilter, IAsyncController, IController,
IAsyncManagerContainer
15. 15
Jak poznat non-SOLID kód?
› Varovné znaky
– Mnoho velkých if, velký počet if ve třídě
– typeof(Subclass)
– if(x is Subclass)
– Přetypování: var concreteObject = (Subclass)someObject
– Mnoho public metod, mnoho metod v interface
– Potřeba implementovat metody vyhozením
• .NET: NotSupportedException
• Java: UnsupportedOperationException
– Lze špatně nebo vůbec testovat
17. Profinit EU, s.r.o.
Tychonova 2, 160 00 Praha 6
Telefon
+ 420 224 316 016
Web
www.profinit.eu
LinkedIn
linkedin.com/company/profinit
Twitter
twitter.com/Profinit_EU
Děkujeme
za pozornost