Skip to main content

Über dieses Buch

Learn how Roslyn's new code generation capability will let you write software that is more concise, runs faster, and is easier to maintain. You will learn from real-world business applications to create better software by letting the computer write its own code based on your business logic already defined in lookup tables.
Code Generation with Rosyln is the first book to cover this new capability. You will learn how these techniques can be used to simplify systems integration so that if one system already defines business logic through lookup tables, you can integrate a new system and share business logic by allowing the new system to write its own business logic based on already existing table-based business logic.
One of the many benefits you will discover is that Roslyn uses an innovative approach to compiler design, opening up the inner workings of the compiler process. You will learn how to see the syntax tree that Roslyn is building as it compiles your code. Additionally, you will learn to feed it your own syntax tree that you create on the fly.
What You Will Learn:• Structure logic to be stored in database design• Build complex conditional logic based on lookup data in the database• Compile code that you generate programmatically• Discover generated code and run it dynamically to implement new business logic• Debug problems in generated code• Deploy and access generated code
Who This Book Is For:
Back end developers in very dynamic fast-paced business environments. Developers focused on integrating different systems across an enterprise should also find this information useful.




Chapter 1. Introduction

You have probably already figured this out, but business logic is hard. It is rarely logical, often doesn't follow discernable patterns, is riddled with exceptions, and changes often and quickly. This can be frustrating but it is the world we live in.

Nick Harrison

Chapter 2. Putting Business Logic in Tables

For each of these types, we will explore what they look like, discuss when they may be applicable, and step through some of the implementation details for proper implementations.

Nick Harrison

Chapter 3. Pulling Table Driven Logic Into Code

You can structure your business logic in a variation or combination of the tables discussed. You have a lot of flexibility here. You just need to understand the business that you are working in and have some creativity.

Nick Harrison

Chapter 4. An Introduction to Roslyn

Roslyn is the new compiler from Microsoft. It represents not only a rewrite of the compilers but also a reimagining of the compilation process in general. In the past, compiling code was a black box. Lines of code went in and a compiled assembly came out, or perhaps a slew of error messages. You could not interrupt this process to get access to any of the intermediate steps. All this changed with Roslyn. Figure 4-1 shows the steps Roslyn takes to compile code and identifies the APIs used to interact with the results at each stage.

Nick Harrison

Chapter 5. Generating Code

So far we have explored the benefits of moving business logic from application code to reference data in the database. You saw how hand-coding business rules in your application logic can lead to brittle code that’s not resilient to change. At the very least, this code can leave you less responsive to changes in the marketplace, which could leave you out of the marketplace all together. We then explored various strategies for storing different types of business rules in variations on a standard decision table.

Nick Harrison

Chapter 6. Deploying Generated Code

So far, we have simply written the generated code to the screen, but this is hardly the only option. Remember Roslyn is the compiler. When you have a generated SyntaxTree, you are already partway through compilation.

Nick Harrison

Chapter 7. Reflecting on Generated Code

Generated code will always be code that was not known at compile time. The whole point of generating code is to make it easier to change the business rules after deployment. This is where reflection comes in. Reflection allows you to access metadata about your code at runtime. With it, you can load an assembly, discover the types in the assembly, create an instance of these types, and systematically execute any method discovered in these types. This is exactly what you need to evaluate new business logic.

Nick Harrison

Chapter 8. Best Practices

We have covered a lot of material in this book. Along the way, we touched on various best practices. Some were expressly called out as tips and notes. Others were stated but a bit more subtly. In this last chapter, we review these best practices as a handy reference.

Nick Harrison


Weitere Informationen

Premium Partner

Neuer Inhalt

BranchenIndex Online

Die B2B-Firmensuche für Industrie und Wirtschaft: Kostenfrei in Firmenprofilen nach Lieferanten, Herstellern, Dienstleistern und Händlern recherchieren.



Best Practices für die Mitarbeiter-Partizipation in der Produktentwicklung

Unternehmen haben das Innovationspotenzial der eigenen Mitarbeiter auch außerhalb der F&E-Abteilung erkannt. Viele Initiativen zur Partizipation scheitern in der Praxis jedoch häufig. Lesen Sie hier  - basierend auf einer qualitativ-explorativen Expertenstudie - mehr über die wesentlichen Problemfelder der mitarbeiterzentrierten Produktentwicklung und profitieren Sie von konkreten Handlungsempfehlungen aus der Praxis.
Jetzt gratis downloaden!