Why We’re Partial to Partial Methods
✕
  • Solutions
    • Legacy Application Modernization
    • Distributed Computing
    • Modern UI/UX
    • Data Visibility
    • Enterprise Application Integration
    • Development Environment Optimization
    • Cloud Migration
    • Security
    • High Availability and Resilience
  • Products
    • Language
    • Development Environment
    • .NET Integration
    • Streaming Integration Platform
    • Web Services Framework
    • Roadmap
  • Services and Support
    • Professional Services Group
    • Developer Support
    • Application Support
  • Learning
    • Events
    • Online Courses
    • White Papers
    • Case Studies
    • Learning Resources
    • Blog
    • Synergy-e-News
  • Company
    • Leadership
    • Careers
    • Contact
    • News
  • +1-916-635-7300
  • Get Support
  • Documentation
  • Resource Center
✕
            No results See all results
            Why We’re Partial to Partial Methods
            • Solutions
              • Legacy Application Modernization
              • Distributed Computing
              • Modern UI/UX
              • Data Visibility
              • Enterprise Application Integration
              • Development Environment Optimization
              • Cloud Migration
              • Security
              • High Availability and Resilience
            • Products
              • Language
              • Development Environment
              • .NET Integration
              • Streaming Integration Platform
              • Web Services Framework
              • Roadmap
            • Services and Support
              • Professional Services Group
              • Developer Support
              • Application Support
            • Learning
              • Events
              • Online Courses
              • White Papers
              • Case Studies
              • Learning Resources
              • Blog
              • Synergy-e-News
            • Company
              • Leadership
              • Careers
              • Contact
              • News
            • +1-916-635-7300
            • Get Support
            • Documentation
            • Resource Center
            ✕
                      No results See all results
                      Why We’re Partial to Partial Methods
                      • Solutions
                        • Legacy Application Modernization
                        • Distributed Computing
                        • Modern UI/UX
                        • Data Visibility
                        • Enterprise Application Integration
                        • Development Environment Optimization
                        • Cloud Migration
                        • Security
                        • High Availability and Resilience
                      • Products
                        • Language
                        • Development Environment
                        • .NET Integration
                        • Streaming Integration Platform
                        • Web Services Framework
                        • Roadmap
                      • Services and Support
                        • Professional Services Group
                        • Developer Support
                        • Application Support
                      • Learning
                        • Events
                        • Online Courses
                        • White Papers
                        • Case Studies
                        • Learning Resources
                        • Blog
                        • Synergy-e-News
                      • Company
                        • Leadership
                        • Careers
                        • Contact
                        • News
                      • Home
                      • Blog
                      • Tech Article
                      • Why We’re Partial to Partial Methods

                      Why We’re Partial to Partial Methods

                      Published by James Sahaj on June 10, 2014
                      Categories
                      • Tech Article
                      Tags
                      • Language


                      A class that implements an interface must implement all members of that interface in order to compile and run successfully. But what if you wanted to give the implementer of a class a choice of whether or not to implement particular methods, and then have all calls associated with any unimplemented methods removed? This is the purpose of partial methods.

                      Partial methods, which were introduced in version 10.1.1a, allow the designer of a class to specify the methods that may be optionally implemented by the programmer who uses that class. Partial methods have two parts: a signature definition and an optional implementation.

                      In this scenario, the designer declares a partial class and then specifies two partial methods, giving only their signatures, but not giving them implementations:

                      namespace ns1
                      public partial class class1
                          static partial method meth1, void
                          parm1, int
                          endmethod
                          static partial method meth1, void
                          parm1, string
                          endmethod
                      
                          public static method testit, void
                          proc
                              ns1.class1.meth1(8);
                              ns1.class1.meth1("hey")
                          end
                      endclass
                      endnamespace

                      The programmer using this class can then optionally define the implementation of the partial methods he wishes to implement:

                      namespace ns1
                      public partial class class1
                          static partial method meth1, void
                          parm1, int
                          proc
                              Console.WriteLine("meth1(int)");
                          endmethod
                          static partial method meth1, void
                          parm1, string
                          proc
                              Console.WriteLine("meth1(string)");
                          endmethod
                      endclass
                      endnamespace
                      
                      main
                      proc
                      ns1.class1.testit()
                      end

                      The output of the program is as follows:

                      meth1(int)
                      meth1(string)

                      So far, there isn’t much difference between a partial method and a regular defined method. However, suppose the implementer of the class only implemented the meth1(int) partial method. When compiling the program, the Synergy .NET compiler would detect that the meth1(string) partial method does not have an implementation and remove all the calls to meth1(string) from the executable at compile time!  So, by not implementing that method the programmer can control which calls will be ignored.

                      Of course, to be able to remove method calls, partial methods must adhere to some basic restrictions:

                      • They must be in a partial class.
                      • They must return void.
                      • Their parameters cannot be marked with an OUT attribute.
                      • They must be private, so they cannot be called outside of the partial class.
                      • They cannot be virtual.

                      Using partial methods allows the designer of a class to give some calling flexibility to the programming consumers of that class by allowing them to determine which methods are implemented, and, in turn, which methods are called. Partial methods were added as part of the 10.1.1a patch. See METHOD-ENDMETHOD in the Synergy/DE documentation for more details on this wonderful new language feature.

                      Share
                      0

                      Leave a ReplyCancel reply

                      This site uses Akismet to reduce spam. Learn how your comment data is processed.

                      • With 40 Years at Synergex, Bill Mooney Is All In
                      • New 12.4 Features Release, 12.4.1.1003
                      • New SDI Release, 2025.06.1647
                      • Simple Strategies to Modernize Your Legacy Code
                      • Unlocking the Power of Modern Web Services: New White Paper Released
                      • Announcements
                      • Beta Testing
                      • Case Studies
                      • Code Exchange
                      • CodeGen
                      • CTO's Thoughts
                      • Development Tools
                      • DevPartner Conference
                      • Education
                      • Events
                      • Harmony Core
                      • Hiring
                      • Industry News
                      • Just for Fun
                      • Licensing
                      • News
                      • Open Source
                      • OpenVMS
                      • President's Thoughts
                      • Professional Services Group
                      • Release Notifications
                      • Security
                      • Software
                      • Software Development
                      • Success Stories
                      • Tech Article
                      • UI
                      • Uncategorized
                      • White Papers

                      STAY CONNECTED with Synergex

                      • Blog
                      • Facebook
                      • LinkedIn
                      • YouTube
                      SOLUTIONS
                      • Legacy Applications Modernization
                      • Modern UI/UX
                      • Data Visibility
                      • Enterprise Application Integration
                      • Development Environment Optimization
                      • Cloud Migration
                      • Security
                      • High Availability
                      PRODUCTS
                      • Language
                      • Development Environment
                      • Connectivity and Open-Source Tools
                      • Release Strategy
                      • Roadmap
                      SUPPORT
                      • Professional Services Group
                      • Developer Support
                      • Application Support
                      LEARNING
                      • Events
                      • Online Courses
                      • Learning Resources
                      • Blog
                      • Synergy-e-News
                      COMPANY
                      • Customers
                      • Leadership
                      • Careers
                      • Contact
                      Why We’re Partial to Partial Methods

                      Privacy  |  Security  |  Terms  |  © 2024 Synergex

                      Out of Scope but Not Out of Mind
                      June 10, 2014
                      Snapshots in a Snap
                      August 6, 2014
                      Out of Scope but Not Out of Mind
                      June 10, 2014
                      Snapshots in a Snap
                      August 6, 2014