concept world in category c#

appears as: world, worlds, world
Functional Programming in C#: How to write better C# code

This is an excerpt from Manning's book Functional Programming in C#: How to write better C# code.

If, on the other hand, the unit you’re testing is an impure function, its behavior will depend not only on its inputs, but possibly also on the state of the program (that is, any mutable state that’s not local to the function under test) and the state of the world (anything outside the context of your program). Furthermore, the function’s side effects may lead to a new state of the program and the world. For example,

  • The date validator depends on the state of the world, specifically the current time.
  • A void-returning method that sends an email has no explicit output to assert against, but it results in a new state of the world.
  • The main goal of this chapter is to teach you to use multi-argument functions in the world of effectful types, so the “effectively” in the title is also a pun! Remember, effectful types are types such as Option (which adds the effect of optionality), Exceptional (exception handling), IEnumerable (aggregation), and others. In part 3, you’ll see several more effects related to state, laziness, and asynchrony.

    The second way, of first lifting the function with Return and then applying arguments, is more readable and more intuitive because it’s similar to partial application in the world of regular values, as shown in listing 8.5.

    hello
    inputs -> hello
    world
    inputs -> world
    q
    inputs END
    C# in Depth

    This is an excerpt from Manning's book C# in Depth.

    The important point is that this code is much more compact and readable (once you understand the syntax, of course). We wanted the list ordered by name, and that’s exactly what the code says. It doesn’t say to sort by comparing the name of one product with the name of another, like the C# 2 code did, or to sort by using an instance of another type that knows how to compare one product with another. It just says to order by name. This simplicity of expression is one of the key benefits of C# 3. When the individual pieces of data querying and manipulation are so simple, larger transformations can remain compact and readable in one piece of code. That, in turn, encourages a more data-centric way of looking at the world.

    No extension methods are called in listing 10.6, just a plain static method. And yes, it really does just print the numbers 0 to 9—I never claimed this code would set the world on fire.

    Typically for a given problem, a programmer is accustomed to building up a solution until it finally meets the requirements. Now, it is possible to extend the world to meet the solution instead of solely just building up until we get to it. That library doesn’t provide what you need, just extend the library to meet your needs.

    Listing 14.8. Printing hello, world twice using Python embedded in C#
    ScriptEngine engine = Python.CreateEngine(); engine.Execute("print 'hello, world'"); engine.ExecuteFile("HelloWorld.py");