One of the most common sources of hidden bugs in business logic? DateTime.UtcNow Here’s the trap: - DateTime.UtcNow > user.SubscriptionEnd Seems harmless, right? But the moment you try to test this logic, you realize the problem: - You can’t control DateTime.UtcNow - Your tests become flaky or complicated - Business rules are tied to infrastructure There are better ways: 1. Inject DateTime as a parameter — simplest, great for small methods 2. Introduce an IClock interface — more scalable, and test-friendly By inverting the dependency on time, you make your domain logic: ✅ Easier to test ✅ More deterministic ✅ Separation of concerns Next time you write a time-based condition, stop and ask: “Will I need to test this?” If the answer is yes, extract the clock. --- Do you want to simplify your development process? Grab my free Clean Architecture template here: https://lnkd.in/e2-HXmNH
Exploring Alternative Solutions
Explore top LinkedIn content from expert professionals.
-
-
What if attack ads aren't as effective as we think? 😱 Contrary to popular belief, bombarding consumers with negative messaging may not always yield the desired results. A study by The Wharton School marketing and economics professor Pinar Yildirim, alongside Gorkem Bostanci and Kinshuk Jerath from Columbia Business School, points that negative advertising can have detrimental effects on product variety, innovation, and consumer welfare. 🤔 Reflection moment: 1️⃣ When was the last time you were swayed by an attack ad? 2️⃣ How do you think consumers perceive brands that resort to negative advertising tactics? 3️⃣ Can you recall a memorable ad campaign that focused on positive messaging rather than attacking competitors? 💡 Tips for effective advertising: 1️⃣ Focus on Positive Differentiation: - Instead of tearing down competitors, highlight your brand's unique strengths and value propositions. 2️⃣ Build Trust Through Transparency: - Foster trust with your audience by maintaining transparency and authenticity in your messaging. 3️⃣ Prioritize Long-Term Brand Building: - Invest in strategies that contribute to long-term brand loyalty and positive associations, rather than short-term gains through attack ads. 4️⃣ Engage in Constructive Competition: - Acknowledge competitors respectfully and focus on outperforming them through innovation and customer-centric initiatives. 5️⃣ Harness the Power of Storytelling: - Craft compelling narratives that resonate with your audience's emotions and values, steering clear of negative rhetoric. Let's challenge the status quo and explore alternative approaches to advertising that prioritize positivity and value creation! What are your thoughts on this? #marketingstrategy #advertisingstrategies #thoughtleadership #thethoughtleaderway
-
Stop Using DateTime.Now in Your APIs – It’s Causing Hidden Bugs! I used to think DateTime.Now was harmless until I ran into time zone issues, inconsistent results, and broken scheduling logic in production. These "hidden bugs" are a common source of frustration for developers. If you’re using DateTime.Now in your ASP.NET Core API, here’s why you should stop and what to do instead! ❌ The Mistake – Using DateTime.Now Directly 𝒗𝒂𝒓 𝒕𝒊𝒎𝒆𝒔𝒕𝒂𝒎𝒑 = 𝑫𝒂𝒕𝒆𝑻𝒊𝒎𝒆.𝑵𝒐𝒘; ❌ What’s Wrong? ▪️ Time Zone Issues – DateTime.Now relies on server time, causing inconsistencies across environments. ▪️ Unit Test Failures – Hard to mock, making tests unreliable and flaky. ▪️ Database Inconsistencies – Different servers store different times, leading to mismatched data. ✅ The Fix – Use DateTimeOffset.UtcNow or Inject IClock ✅ Use DateTimeOffset.UtcNow for consistency 𝒗𝒂𝒓 𝒕𝒊𝒎𝒆𝒔𝒕𝒂𝒎𝒑 = 𝑫𝒂𝒕𝒆𝑻𝒊𝒎𝒆𝑶𝒇𝒇𝒔𝒆𝒕.𝑼𝒕𝒄𝑵𝒐𝒘; Why? ✔ Time-zone independent – Ensures consistency across environments. ✔ Retains offset information – Prevents time zone ambiguity when converting to local time. ✔ Ideal for distributed systems – UTC is the standard for databases and global applications. ✅ Return API Timestamps in ISO 8601 Format return Ok(new { Timestamp = DateTimeOffset.UtcNow.ToString("o") }); // "2024-02-09T12:34:56.789Z" Why? ✔ Ensures compatibility – ISO 8601 is universally supported across platforms. ✔ Eliminates ambiguity – The "o" format preserves the time zone offset for accurate conversions. ✅ For Testability, Use an IClock Abstraction Instead of calling DateTimeOffset.UtcNow directly, inject a clock service inject IClock into your services for mocking in tests Why? ✔ Reliable unit tests – Mocking IClock ensures predictable time-dependent testing. ✔ Decouples from system time – Increases flexibility and maintainability. ❗ Things to Watch Out For Convert UTC Before Displaying – Always convert UTC to the user's local time. ▪️ Use IClock Only When Needed – Avoid over-engineering; DateTimeOffset.UtcNow suffices for simple cases. ▪️ Store UTC in Databases – Use datetimeoffset, not datetime, and convert on retrieval. ▪️ Handle Time Zones Properly – Consider DST, user preferences, and IANA time zones (America/New_York). ▪️ Test Time Logic Correctly – Use virtual time and mocks for reliable tests. ▪️ Always Mock IClock – Never rely on the system clock in tests. ▪️ Global vs. Local IClock – Choose wisely for large applications. How This Fix Improves Your API? ▪️No time zone headaches – Always store timestamps in UTC. ▪️Fully testable – Mock time easily for unit tests. ▪️Better logging & debugging – Consistent timestamps across environments. ▪️Frontend-ready – ISO 8601 ensures correct parsing. ▪️ Improved data integrity – UTC storage prevents data loss & ambiguity. Tip: Store timestamps in UTC and convert to the user's local time only when displaying! Still using DateTime.Now? Let’s discuss! Share your experiences below!
-
Stop Testing the “Cut-Off Fish Tails” 🐟 A little girl once saw her mom cut off a large portion of the head and tail of a fish before cooking. When she asked why, Mom said, “That’s how my mother taught me.” Grandma gave the same answer. Finally, Great-Grandma laughed, “In 1935, my pan was too small. I had to cut the fish to make it fit.” The reason was valid then… but irrelevant now. The practice lived on because no one questioned it. In software testing, the same thing happens: We keep following a workflow, process, or approach just because “it’s how we’ve always done it.” Sometimes, we’re testing steps that are: 1. Leftovers from an older version 2. Part of a process the business no longer follows 3. Temporary fixes that became permanent habits Great testers don’t just check the box. They investigate: 1. Why is this step here? 2. Does it still serve the user? 3. Is it solving a real problem or is it just a practice that is followed? If we don’t ask, we end up spending time on “cut-off fish tails” , while missing the things that truly matter to users. What’s one outdated testing practice you’ve seen carried forward without question? #SoftwareTesting #QualityAssurance #TestMetry #QualityEngineering
-
🧠 Are Best Practices Overrated? I was on a podcast today and said I loved my role because I get to write the playbook vs follow someone else's! Consider this. 🦒 Best practices are often treated as gospel—tried-and-true methods that promise stability and efficiency. But here’s the catch: they’re based on past success, not future opportunity. And if you’re aiming to innovate, disrupt, or push boundaries, best practices might actually limit you. Here’s why: 👉 Best practices reinforce the status quo. They’re designed to minimize risk and ensure predictability. That’s valuable for stability, but if your goal is to break new ground, you can’t rely solely on yesterday’s playbook. 👉 Innovation thrives on experimentation. Disruptive ideas often emerge from questioning or outright breaking best practices. Think about how Netflix eliminated late fees, Tesla bypassed traditional dealerships, or OpenAI approached AI accessibility. These companies didn’t follow—they led. 👉 Best practices can create a false sense of security. You might feel like you’re doing everything “right,” but in fast-moving industries like #AI, #blockchain, #Quantum or #Web3, what’s “right” today might already be outdated tomorrow. 👉 Context matters. What works for one company, team, or market may not work for yours. Copying success without adapting to your unique strengths or challenges often leads to mediocrity—not greatness. So, what’s the alternative? ⁉️ Rather than asking, “What are the best practices?” ask: 1. What’s never been tried before? 2. What’s unique to us? 3. How can we design for the future, not the past? 💁♀️ The takeaway: Best practices are a great starting point—but they’re not the finish line. The companies that thrive are the ones willing to break the rules, reinvent processes, and set new standards. What do you think? Are best practices holding us back, or are they still essential for growth? Share your thoughts in the comments! ⬇️
-
A provocation: 'Best practices' are sometimes the least helpful. It's easy to want to replicate what may have worked in the past. However, transformative progress demands questioning, not copying. There are endless static repositories of best practices. Today's approaches will not satisfy tomorrow's needs or dreams. Yesterday's formulas are merely inputs—not starting points, and certainly not templates for tomorrow's world. Practitioners, let's end the grandstanding of best practices; the obsession of what worked in a different context at a different time. Widen your field of view. Avoid becoming attached to best practices. It does little more than lead to mediocrity and sloppy solutions. Instead, ask as many 'what if' questions as you can. There are no convenient ways to solve a complex puzzles. #innovation #questioning #bestpractices #futureofwork #systemschange #systemsthinking #thinking #leadership #socialimpact #impact #management
-
This Apple ad explains why 99% of cold emails fail. (It's a lesson every salesperson needs) A mistake in cold emailing is sounding too "hype-y". Messages like: - "We can skyrocket your revenue overnight!" - "Double your conversions in just 7 days!" Do these claims sound believable to you? Probably not. They remind me of those infomercials promising six-pack abs in five minutes a day. Hype is all about exaggeration. But in today's world, it sets off alarm bells. Prospects are skeptical. They've heard it all before. So what's the alternative? Be authentic. Instead of "10X your monthly revenue" (hype), Try "Let's discuss your revenue goals." Like the classic Apple ad from 1979. It didn't shout "Buy now!" It invited you to explore "How to buy." See the difference? One pushes. The other guides. When you dial down the hype, people lower their guard. They become open to your message. So ask yourself: Are your cold emails shouting "Buy now"? Or are they starting a conversation? Remember: Less hype, more authenticity. P.S. How do you react to hype in sales messages?
-
I remember once being told, "That's just how we do things." It felt like a door was slammed shut on new ideas. In my career, I've spent years challenging this mindset. I've seen teams rethink their meeting structures, leading to more productive discussions. I've witnessed companies revamp their feedback systems, resulting in higher employee satisfaction. We can uncover more efficient, innovative, and engaging working methods by simply questioning outdated practices. I don't accept the status quo. Why should we? We need to ask tough questions to find better solutions. This mindset has led to real, tangible improvements in every project I've taken on. As a result, I love working with a team that also questions the status quo. Elixirr wouldn't be called the Challenger Consultancy if it wasn't for our mindset and approach to consulting. Ask yourself today: Are we questioning enough? Are we settling for "the way things are done" or pushing for better? What's one outdated practice you've successfully changed?
-
Using DateTimeOffset.UtcNow in your code? I made the same mistake for years. The problem is that it makes your code super hard to test since you'd have to rely on specific dates or use tricks to change the system time. Need to verify that some logic runs only on Sundays? Can't. Need to check that the current time was set on a property? Can't. But, fortunately, there's a smarter way to deal with time: use a 𝘁𝗶𝗺𝗲 𝗮𝗯𝘀𝘁𝗿𝗮𝗰𝘁𝗶𝗼𝗻. With a time abstraction, you can easily switch between real-time and fixed-time scenarios. For instance, you can introduce an abstract 𝗧𝗶𝗺𝗲𝗣𝗿𝗼𝘃𝗶𝗱𝗲𝗿 with a virtual 𝗚𝗲𝘁𝗨𝘁𝗰𝗡𝗼𝘄() method. GetUtcNow() can, by default, return the current system time, but your unit tests can easily substitute that with a fixed time. And the good thing is that .NET 8 comes with its own ready-to-use TimeProvider! No more excuses to avoid this simple but incredibly useful best practice. It could save you a lot of time (pun intended) in the future!
-
Hype & virality as a strategy is overrated. We generated ~500+ high-intent leads in a couple weeks with a simple principle: make it effortless for people to experience the value before asking them to believe in it. We call it Full-Funnel Personalisation. Someone sees creative about a specific pain (e.g., the loneliness of a breakup) → two clicks later they’re in a purpose built SMS chat with our AI mind coach designed to help with that exact problem. This approach is only possible now as AI has removed two historic bottlenecks: 1. Creative velocity - we can spin up hyper-specific assets in minutes. 2. Personalised product onboarding - we can create new bespoke conversational flows for pain points and personas in hours, not days. The result? 50% lower CPL than our “hype” videos and 300% lower than a generic waitlist funnel. Hype earns attention. Understanding and solving problems earns trust. Which one do you think turns into paid adoption faster? Don’t get us wrong we still play into hype (example video below), but we over index on product value, even at top of funnel. An article of mine "Distribution beyond hype" in the comments.