{"id":22065752,"url":"https://github.com/karenpayneoregon/fluentpatternvisualbasic","last_synced_at":"2025-03-23T18:17:21.241Z","repository":{"id":110840606,"uuid":"163779042","full_name":"karenpayneoregon/FluentPatternVisualBasic","owner":"karenpayneoregon","description":"Build pattern code sample","archived":false,"fork":false,"pushed_at":"2019-03-02T00:41:10.000Z","size":146,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-29T00:29:25.266Z","etag":null,"topics":["patterns","vbnet"],"latest_commit_sha":null,"homepage":"","language":"Visual Basic","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/karenpayneoregon.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-01-02T01:11:32.000Z","updated_at":"2021-05-14T18:00:01.000Z","dependencies_parsed_at":null,"dependency_job_id":"bc4c1605-49b8-42a6-8a74-0c9d753bf427","html_url":"https://github.com/karenpayneoregon/FluentPatternVisualBasic","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/karenpayneoregon%2FFluentPatternVisualBasic","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/karenpayneoregon%2FFluentPatternVisualBasic/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/karenpayneoregon%2FFluentPatternVisualBasic/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/karenpayneoregon%2FFluentPatternVisualBasic/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/karenpayneoregon","download_url":"https://codeload.github.com/karenpayneoregon/FluentPatternVisualBasic/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245144978,"owners_count":20568056,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["patterns","vbnet"],"created_at":"2024-11-30T19:21:47.306Z","updated_at":"2025-03-23T18:17:21.216Z","avatar_url":"https://github.com/karenpayneoregon.png","language":"Visual Basic","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n\n# Fluent Design pattern\nThis repository provides code samples for writing code using \nfluent desing pattern with VB.NET programming language.\n\n[TechNet article](https://social.technet.microsoft.com/wiki/contents/articles/52583.vb-net-fluent-builder-design-pattern.aspx)\n\n\n\u003eWhat exactly constitutes a fluent interface? Fowler describes the way that processes are defined by creating the various objects and then wiring them up together by means of an internal domain-specific language (DSL). The intention is to produce an API that is readable and flows. He suggests using method chaining, with nested functions and object scoping. There are several approaches to implementing this depending on the language that is used. \n\n\n#### Advantages of Builder Design Pattern\n- The parameters to the constructor are reduced and are provided in highly readable method calls.\n- Builder design pattern also helps in minimizing the number of parameters in constructor and thus there is no need to pass in null for optional parameters to the constructor.\n- Object is always instantiated in a complete state\n- Immutable objects can be build without much complex logic in object building process.\n\n#### Disadvantages of Builder Design Pattern\n- The number of lines of code increase at least to double in builder pattern, but the effort pays off in terms of design flexibility and much more readable code.\n- Requires creating a separate ConcreteBuilder for each different type of class item.\n\nExample for building a report\n```csharp\nNamespace ProductBuilderClasses\n\n    Public Class ProductBuilderDemo\n        Public Sub New()\n            Dim products = New List(Of Product) From {\n                    New Product With {.Name = \"Monitor\", .Price = 200.5},\n                    New Product With {.Name = \"Mouse\", .Price = 20.41},\n                    New Product With {.Name = \"Keyboard\", .Price = 30.15}}\n\n            Dim builder = New ProductStockReportBuilder(products)\n            Dim director = New ProductStockReportDirector(builder)\n            director.BuildStockReport()\n\n            Dim report = builder.GetReport()\n            Console.WriteLine(report)\n        End Sub\n    End Class\nEnd Namespace\n```\n\nExample for updating a SQL-Server record \n```csharp\nDim result = customerReader.\n        Begin().\n        UpdateContactPhone(contact.Id).\n        SetContactPhoneTypeAs(contact.PhoneType).\n        WithPhoneNumber(contact.PhoneNumber).\n        PhoneStatusIsActive(contact.Active).\n        UpdateContactPhoneDetails()\n```\n \n\nExample working with a SQL-Server table read operation chain.\n```csharp\nbindingSourceCustomers.DataSource = customerReader.\n    Begin().\n    OrderBy(\"LastName\").\n    DescendingOrder.\n    WithoutIdentifiers().\n    ReadAllCustomersRecords()\n```\nBroken chain\n```csharp\nDim customerReader = New CustomersBuilder\n\ncustomerReader.Begin()\ncustomerReader.OrderBy(columnNamesComboBox.Text)\n\nIf decendingOrderCheckBox.Checked Then\n    customerReader.DescendingOrder()\nElse\n    customerReader.AscendingOrder()\nEnd If\n\nbindingSourceCustomers.DataSource = customerReader.ReadAllCustomersRecords()\n```\n\nExample sending email\n```csharp\nDim mailer As New MailBuilder()\n\nmailer.CreateMail(GmailConfiguration1).\n    WithRecipient(\"karen@comcast.net\").\n    WithCarbonCopy(\"mary@gmail.com\").\n    WithSubject(\"Test\").\n    AsRichContent().\n    WithHtmlView(\"\u003cp\u003eHello \u003cstrong\u003eBob\u003c/strong\u003e\u003c/p\u003e\").\n    WithPickupFolder().\n    WithTimeout(2000).\n    SendMessage()\n```\n\n\n---\n\n### Requires\n- Microsoft [Visual Studio](https://visualstudio.microsoft.com/) 2017 or higher\n- Microsoft [SQL-Server](https://www.microsoft.com/en-us/sql-server/sql-server-2017?\u0026OCID=AID739534_SEM_fkhHI4O5\u0026MarinID=sfkhHI4O5_258104145762_sql%20server_e_c__57166984510_aud-397602258452:kwd-14998960_) 2012 or higher\n\n### Build steps\n\nRun the following data scripts against your SQL-Server.\n- [emailDatabase.sql](https://github.com/karenpayneoregon/FluentPatternVisualBasic/blob/master/emailDatabase.sql) \n- [NorthWindParialScrript.sql](https://github.com/karenpayneoregon/FluentPatternVisualBasic/blob/master/NorthWindPartialScript.sql) \n- [CreateDatabaseTablesAndPopulate.sql](https://github.com/karenpayneoregon/FluentPatternVisualBasic/blob/master/NonMailBuilderExamples/CreateDatabaseTablesAndPopulate.sql) \n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkarenpayneoregon%2Ffluentpatternvisualbasic","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkarenpayneoregon%2Ffluentpatternvisualbasic","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkarenpayneoregon%2Ffluentpatternvisualbasic/lists"}