<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Goce Bonev on Medium]]></title>
        <description><![CDATA[Stories by Goce Bonev on Medium]]></description>
        <link>https://medium.com/@goceb?source=rss-d34ee957297e------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Ze-Y3QI2qHOHl_3tMSV0qg.jpeg</url>
            <title>Stories by Goce Bonev on Medium</title>
            <link>https://medium.com/@goceb?source=rss-d34ee957297e------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 07:28:16 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@goceb/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[From Fragile Code to Resilient Systems: Managing Complexity and Building Systems That Last]]></title>
            <link>https://medium.com/@goceb/from-fragile-code-to-resilient-systems-managing-complexity-and-building-systems-that-last-b56fb257a461?source=rss-d34ee957297e------2</link>
            <guid isPermaLink="false">https://medium.com/p/b56fb257a461</guid>
            <category><![CDATA[hexagonal-architecture]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[strangler-fig-pattern]]></category>
            <category><![CDATA[domain-driven-design]]></category>
            <category><![CDATA[legacy-code]]></category>
            <dc:creator><![CDATA[Goce Bonev]]></dc:creator>
            <pubDate>Thu, 04 Sep 2025 10:05:08 GMT</pubDate>
            <atom:updated>2025-10-19T19:53:45.572Z</atom:updated>
            <content:encoded><![CDATA[<h4>Almost ten years have passed since we first embarked on a journey that transformed the way we do software. This is the story of our evolution, experiences, lessons learned, and the changes that have shaped our approach to software development over the past decade.</h4><p>For years, we prided ourselves on our ability to quickly build projects. We leveraged every tool, framework, and best practice considered standard in the industry to gain a competitive edge. But then, we encountered a project that made us take a step back and reevaluate our entire approach.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dV7WXzOGMAoTaXHNUttXaQ.png" /></figure><h3>The Project</h3><p>The project started off well. We used a well-known ActiveRecord-based framework, had skinny controllers, fat models, and even fatter services. We had already built 180 use cases and had plans for at least 400 more. However, as we advanced in the project, it became clear that things were not going as planned.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LQktTgbylevklMYl9t6Ecw.png" /><figcaption>Skinny controllers, fat models, and even fatter services. Our Big Ball of Mud (or Big Ball of Spaghetti), Image credit: subpng.com</figcaption></figure><h3>The Breaking Point</h3><p>As we dived deeper into this project, we found ourselves sinking into quicksand. The complexity was skyrocketing, and each new feature seemed to introduce as many problems as it solved. Our technical debt was growing, and the codebase was becoming increasingly difficult to manage.</p><p><strong>Rather than delivering value, we were acting as firefighters</strong> — extinguishing one fire only for another to flare up. Developers were growing increasingly unhappy and disengaged. It was clear that something needed to change — and quickly.</p><h3>Discovering Domain-Driven Design: A Catalyst for Change</h3><p>As we struggled with our increasingly complex project, Domain-Driven Design appeared on our radar.</p><p>Quick to see immediate results, <strong>we skimmed over the strategic design part </strong>and went <strong>directly to tactical design</strong> since it looked way more actionable. We were drawn to the technical, code-focused aspects of DDD — value objects, aggregates, repositories etc.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p-IHkQ09dV4wgqkh3uJoPg.png" /><figcaption>Strategic what ?!@$# skip that….</figcaption></figure><p>Implementing these alone<strong> </strong>had an immediate impact, our code became cleaner, more maintainable and <strong>more pleasant to work on</strong>. In the process our code base shrank by 14% (LOC).</p><p>While we immediately adopted the use ubiquitous language, we had only a <strong>limited understanding of bounded contexts</strong>. This partial application of DDD (DDD Lite) had a downside: we found ourselves <strong>over-engineering parts of the application that were far from the core domain, wasting both time and energy.</strong></p><p>As we dived deeper, it became clear that we were missing on the real power of DDD by not exploring the strategic design part. We realized it offered invaluable tools for <strong>dissecting our complex project into more manageable pieces</strong>. It helped us <strong>identify the core business subdomains</strong>, assess their individual complexity, and allocate resources more effectively.</p><p>We began to use bounded contexts to set boundaries and define responsibilities, which cut down on the <strong>amount of wasted effort and cleared up a lot of confusion</strong>. Context maps further guided our understanding of how these bounded contexts interact, enabling us to make smarter decisions on architecture and patterns.</p><p>With the adoption of the ubiquitous language, our development process transformed into a <strong>true collaboration between developers and domain experts</strong>. The most impactful insights and decisions emerged over cups of coffee, direct conversations and whiteboard sessions.</p><p>This holistic embrace of DDD has significantly shifted how we approach <a href="https://thinkweb.io/services/custom-software">custom software development</a>. It’s not just about coding, completing tasks and features anymore; <strong>it’s about truly understanding the problem domain, the interactions between people and processes involved, and motivations driving decision-making</strong>. By <strong>actively collaborating</strong>, rather than being passive observers, we engage more deeply with the core issues at hand.</p><p>This proactive involvement allows us to craft solutions that are not only technically sound but also <strong>closely aligned with the real-world needs and dynamics</strong> of each project. This way, we’re not just solving problems, but also enriching our understanding and response to the challenges at hand, leading to more effective and meaningful outcomes.</p><h3>A Shift in Mindset: From Database-Centric to Domain-Centric</h3><p>Back to our transformation. Everything we were doing required moving away from a database-first approach, where code and design were heavily influenced by the database structure. Instead of being burdened by infrastructure concerns, we began tackling the complexities of the business problem first. This shift was liberating and allowed us to defer data storage decisions and avoid early commitments that could box us in.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*82d110z6G8Yw-hr8BrJ1Jw.jpeg" /><figcaption>Infrastructure first to infrastructure last</figcaption></figure><h3>Embracing Incremental Change</h3><p>We had a lot of things to change, but we knew doing it at once would be a recipe for disaster. So, we took baby steps. The <a href="https://martinfowler.com/bliki/StranglerFigApplication.html">Strangler Fig pattern</a> became our go-to strategy, allowing us to incrementally replace parts of our system without causing chaos and unneeded headaches.</p><p>Our primary goal was to create an <strong>expressive domain model for our core subdomains</strong> while ensuring our code base provided us with the flexibility we needed.</p><p>To achieve this, we started removing dependencies of the framework in the domain model and application layers. This gave us the ability to upgrade or even swap it out entirely if needed since. In fact, we eventually went fully framework-less, relying mostly on PSR compatible packages to connect the pieces. Adopting this domain-first approach also allowed us to delay decisions on persistence and everything infrastructure related until the very last moment, ensuring that when they were made, they were informed decisions rather than hunches, bias or personal preferences.</p><h3>From Language Primitives to Domain Objects</h3><p>During this process, we switched from using language primitives to domain-specific objects, capturing our business logic in a way that felt more expressive and natural.</p><p>We started with the introduction of value objects and repositories, which led to the phasing out of active record models in favor of aggregates. Over time, we established clear distinctions between domain logic, application logic, and infrastructure, even standardizing this as the default folder structure in our modules.</p><h3>Hexagonal Architecture</h3><p>With our domain model and application layer isolated from the infrastructure it turned out that we had adopted hexagonal architecture naturally.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XkYdkOG9OXqvq8US-BhKPg.png" /><figcaption>Interfaces and corresponding implementations within our system</figcaption></figure><p>Recognizing the value of having the core business logic decoupled from external concerns, and the ability to swap or modify adapters without affecting the core, we made it a strong requirement for all core subdomains.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xoVw9Zn1Nxbktnmxv_Ks0g.png" /><figcaption>Moving parts of the monolith to AWS lambdas</figcaption></figure><p>Thanks to hexagonal, we had the agility to experiment and transition parts of our application to serverless. As our application grew and background tasks began consuming nearly all of the CPU, this helped us move them out of the monolith and onto AWS Lambda in under a day, <strong>simply by changing the input and output implementations</strong>.</p><p>In retrospect, our journey into Domain-Driven Design has been as much about unlearning old habits as it has been about learning new ones. This journey, triggered by the complexities of a single project, has fundamentally transformed our approach to software development. It has shifted our focus from merely reacting to problems to proactively crafting robust solutions.</p><p>From dealing with inherently fragile systems faced with complex business logic, our adoption of DDD has been instrumental in building a resilient architectural and reasoning foundation. This transformation has empowered our team and our business, enabling us to focus on delivering tangible value and enhancing developer happiness. By embracing DDD, we successfully transformed a previously fragile big ball of mud into a robust and scalable system, ready to meet the evolving challenges of its industry.</p><h3>Key Takeaways</h3><ul><li>Quick wins can hide deeper problems as projects grow. Surface-level fixes do not solve long-term complexity.</li><li>Adding features without structure increased technical debt and led to burnout.</li><li>Domain-Driven Design (DDD) helped simplify the codebase and made work more enjoyable. Cleaner code led to a significant reduction in LoC.</li><li>Moving from language primitives to domain objects made code clearer and closer to real business logic.</li><li>Skipping the strategic side of DDD wasted energy and let to overengineering. Strategic DDD breaks big problems into manageable pieces.</li><li>Using bounded contexts and context maps cut down confusion and led to better decisions.</li><li>Switching from thinking database first to domain first gave more flexibility and better long-term results.</li><li>Making changes bit by bit, rather than all at once, reduced risk. The Strangler Fig pattern was key for safe improvements.</li><li>Hexagonal architecture allowed parts to move from monolith to serverless with little effort and without breaking anything.</li><li>Adopting DDD was a big mindset shift. The payoff: happier developers, clearer systems, ready for whatever comes next.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b56fb257a461" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Password Reuse Prevention: How to Implement Secure Password History]]></title>
            <link>https://medium.com/@goceb/password-reuse-prevention-how-to-implement-secure-password-history-1e1e522b402f?source=rss-d34ee957297e------2</link>
            <guid isPermaLink="false">https://medium.com/p/1e1e522b402f</guid>
            <category><![CDATA[security]]></category>
            <category><![CDATA[passwords]]></category>
            <category><![CDATA[password-security]]></category>
            <category><![CDATA[password-management]]></category>
            <dc:creator><![CDATA[Goce Bonev]]></dc:creator>
            <pubDate>Thu, 14 Sep 2023 09:40:32 GMT</pubDate>
            <atom:updated>2025-10-28T19:22:30.979Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ucpPww6_RareA3WvHmXcxg.png" /></figure><h4>Password security is a critical concern that can’t be overlooked in today’s digital age. With 70% password reuse rate among users who had their data exposed in breaches¹, it’s evident that more needs to be done. This article focuses on implementing a basic password reuse prevention feature as part of your authentication system.</h4><h3>The Problem with Password Reuse</h3><p>Password reuse amplifies the consequences of data breaches, turning a single security incident into a potential gateway for multiple points of unauthorized access. When a set of credentials is compromised, it’s not just one account that’s at risk. If the same password is used across multiple platforms, attackers can exploit this vulnerability to gain widespread access. This creates a domino effect, making password reuse an urgent issue to address in any authentication system.</p><h3>What is Password Reuse Prevention?</h3><p>Password reuse prevention is a security feature implemented within authentication systems to prevent users from reusing a set of previously used passwords. The primary goal is to mitigate the risks associated with password reuse, which can lead to unauthorized access across multiple accounts when one is compromised.</p><p>In practical terms, when a user tries to change or reset their password, the system compares the new password against a stored list of the user’s previous passwords. If the new password matches any in the list, the system will prevent the password change and prompt the user to try a different password.</p><p>This feature is beneficial for several reasons:</p><ul><li>By ensuring that users are regularly creating unique passwords, you diminish the risk of a security breach affecting multiple accounts.</li><li>This system implicitly educates users about good security hygiene by enforcing a practice of varied, unique credentials.</li><li>Many regulatory frameworks require companies to enforce strong password policies, including not allowing the reuse of previous passwords.</li></ul><p>Implementing password history is a proactive step toward better security hygiene and is often a recommended or required practice in various industry security frameworks and regulations. However, it’s crucial to acknowledge that storing this history does introduce additional security considerations, as you’re increasing the amount of sensitive data that needs to be securely stored. As such, it’s essential that these historical hashes be given the same level of protection as current user credentials.</p><h3>Implementing Secure Password History</h3><p>Implementing a secure password history involves several components, each of which plays a crucial role in enhancing your authentication system’s security.</p><h4>Password Hashing</h4><p>The PasswordHasher ensures that any implementing class can securely hash and validate passwords. Its primary functions are to transform a plaintext password into a secure hash and to verify if a given plaintext password corresponds to a stored hash.</p><pre>interface PasswordHasher<br>{<br>    public function hashPassword(string $plaintextPassword) : string;<br>    public function isPasswordValid(string $plaintextPassword, string $hashedPassword) : bool;<br>}</pre><p>Secure hashing algorithms like bcrypt or Argon2 are recommended to ensure optimal security. For more details, you can consult the <a href="https://cheatsheetseries.owasp.org/cheatsheets/Password_Storage_Cheat_Sheet.html">OWASP Password Storage Cheat Sheet</a>.</p><h4>The Password History</h4><p>The PasswordHistory class encapsulates the logic needed to prevent password reuse. By maintaining a list of a user&#39;s most recent passwords, it can effectively stop the reuse of older, possibly compromised, passwords.</p><p>Each instance of the password history is tied to a specific user, ensuring that each one has its own isolated history of previously used passwords.</p><p>Adding a new password to the list is a straightforward operation. If the list of stored hashes exceeds a predefined limit, the class will automatically remove the oldest hash to make room for the new one. This constant turnover ensures that only the most recent passwords are considered during any password change or reset action.</p><p>Another important feature is the ability to validate new passwords against the stored history. By iterating over its list of previous hashed passwords and using the provided PasswordHasher for validation, it can check if the password is reused.</p><pre>final class PasswordHistory<br>{<br>    private const PASSWORD_HISTORY_LENGTH = 10;<br><br>    public function __construct(<br>        public readonly UserId $userId,<br>        private array $passwords<br>    ) {<br>    }<br><br>    public function add(string $hashedPassword) : void<br>    {<br>        $this-&gt;passwords[] = $hashedPassword;<br>        $this-&gt;passwords = array_slice($this-&gt;passwords, -self::PASSWORD_HISTORY_LENGTH, self::PASSWORD_HISTORY_LENGTH);<br>    }<br><br>    public function contains(string $plaintextPassword, PasswordHasher $passwordHasher) : bool<br>    {<br>        foreach ($this-&gt;passwords as $historicalPasswordHash) {<br>            if ($passwordHasher-&gt;isPasswordValid($plaintextPassword, $historicalPasswordHash)) {<br>                return true;<br>            }<br>        }<br>        return false;<br>    }<br>}</pre><p>When deciding on the number of previous passwords to store in the history, it’s crucial to find a balance that aligns with your organization’s data retention policies. While an extensive history can improve security by preventing the reuse of many old passwords, storing too many could introduce increased risks, especially in the event that the password history itself is compromised.</p><h4>Storage</h4><p>It’s crucial to ensure that the storage containing old password hashes maintains the same level of access control and encryption as your main user data. Just because they’re “old” doesn’t mean they are less sensitive. Any compromise here can defeat the purpose of implementing a secure password history. To keep things flexible and maintainable, the storage is abstracted behind a PasswordHistoryRepository interface, allowing you to plug in any secure storage mechanism.</p><pre>interface PasswordHistoryRepository<br>{<br>    public function store(PasswordHistory $passwordHistory) : void;<br>    public function find(UserId $userId) : PasswordHistory;<br>}</pre><h4>Putting Everything Together</h4><p>With the fundamental components in place for managing password history, it’s time to turn our attention to integrating this functionality into the application.</p><p>In the example below, the ChangePasswordHandler runs a series of checks: verifying the old password, ensuring the new one hasn&#39;t been used before, and then safely updating the current password—all while maintaining a secure record of previous passwords.</p><pre>final class ChangePasswordHandler<br>{<br>    public function __construct(<br>        private readonly UserRepository $userRepository,<br>        private readonly PasswordHistoryRepository $passwordHistoryRepository,<br>        private readonly PasswordHasher $passwordHasher<br>    ) {<br>    }<br><br>    public function handle(ChangePassword $command) : void<br>    {<br>        $user = $this-&gt;userRepository-&gt;getById($command-&gt;userId);<br>        if (!$this-&gt;passwordHasher-&gt;isPasswordValid($command-&gt;currentPassword, $user-&gt;hashedPassword())) {<br>            throw new PasswordDoesNotMatchException();<br>        }<br><br>        $passwordHistory = $this-&gt;passwordHistoryRepository-&gt;find($user-&gt;id());<br>        if ($passwordHistory-&gt;contains($command-&gt;newPassword, $this-&gt;passwordHasher)) {<br>            throw new NewPasswordIsSameAsOneOfOldException();<br>        }<br><br>        $hashedPassword = $this-&gt;passwordHasher-&gt;hashPassword($command-&gt;newPassword);<br>        $user-&gt;changePassword($hashedPassword);<br>        $this-&gt;userRepository-&gt;store($user);<br><br>        $passwordHistory-&gt;add($hashedPassword);<br>        $this-&gt;passwordHistoryRepository-&gt;store($passwordHistory);<br>    }<br>}</pre><p>This logic should be applied uniformly, whether the user is changing their password or resetting it. Ensuring this consistency across different password-related actions further strengthens the system’s resilience against security risks associated with password reuse.</p><h4>UI Considerations</h4><p>When a user attempts to reuse a password, the system should provide a clear but secure error message. While it’s essential to keep users informed, it’s equally important to not divulge too much information that could be a security risk.</p><p>By carefully crafting your frontend messages and cues, you can provide a seamless user experience that aligns with your backend security measures.</p><h3>Beyond the Core Implementation</h3><p>While a robust password history system offers substantial security benefits, going the extra mile can make your system even more secure. For instance, adding a list of passwords known to be compromised in public breaches provides an extra safeguard. Likewise, creating a list of organization-specific disallowed passwords, such as those using the company name, can prevent easily guessable combinations.</p><p>When a user’s password is rejected, it’s important to provide clear but secure feedback, so they understand why it was rejected. By enhancing the core security features of your password history system with these additional measures, you not only strengthen your system’s defenses but also increase user trust.</p><p>If you’re designing authentication systems or need help applying secure-by-design principles in PHP, our team at ThinkWeb specializes in <a href="https://thinkweb.io/services/php-development">custom PHP development</a> and <a href="https://thinkweb.io/insights/bgphp-virtual-meetup-8-security-edition">application security</a> for regulated industries.</p><p>Sources</p><p>¹ 70% Password Reuse: Password Security Needs a Forced Reset [<a href="https://spycloud.com/blog/password-reuse/">source</a>]</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1e1e522b402f" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>