Advertisement
Guest User

Untitled

a guest
Jun 5th, 2024
965
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.45 KB | None | 0 0
  1. // === IDL-CREATION-GUIDLINES ===
  2. // **Object Oriented**: Use OO Design.
  3. // **Design Patterns**: Use Factory, Builder and Strategy patterns where possible
  4. // ** Complex parameters JSON : Use JSON where primitive params are not possible and document them in IDL like "Expected JSON format: { "key1": "type1", "key2": "type2" }"
  5. // == !! BEGIN IDL TEMPLATE !! ===
  6. // === CODE-CREATION-RULES ===
  7. // **Strict Typing**: Always use strict typing. Avoid using ambiguous or variant types.
  8. // **Primitive Types**: Favor the use of primitive types wherever possible.
  9. // **Portability Mandate**: Python code must be written with the intent to be ported to Java, Go, and JavaScript. Consider language-agnostic logic and avoid platform-specific dependencies.
  10. // **No Side Effects**: Functions should be pure, meaning their output should only be determined by their input without any observable side effects.
  11. // **Testability**: Ensure that every function and method is easily testable. Avoid tight coupling and consider dependency injection where applicable.
  12. // **Documentation**: Every function, method, and module should be thoroughly documented, especially if there's a nuance that's not directly evident from its signature.
  13. // **Contractual Obligation**: The definitions provided in this IDL are a strict contract. All specified interfaces, methods, and constraints must be implemented precisely as defined without deviation.
  14. // =======================
  15.  
  16. module GenericSystemName {
  17.  
  18. // Interface for a generic entity
  19. interface EntityName {
  20.  
  21. // Action/method definition
  22. // Preconditions:
  23. // - Define any preconditions here.
  24. // - Expected JSON format: { "key1": "type1", "key2": "type2" }
  25. // Postconditions:
  26. // - Define the expected outcomes here.
  27. returnType methodName(parameterType parameterName);
  28.  
  29. // Additional methods...
  30. };
  31.  
  32. // Another entity or component
  33. interface AnotherEntity {
  34.  
  35. // Action/method definition
  36. // Preconditions:
  37. // - Define any preconditions here.
  38. // - Expected JSON format: { "key1": "type1", "key2": "type2" }
  39. // Postconditions:
  40. // - Define the expected outcomes here.
  41. returnType anotherMethodName(parameterType parameterName);
  42.  
  43. // Additional methods...
  44. };
  45.  
  46. // == !! END IDL TEMPLATE !! ===
  47.  
  48. // EXAMPLE
  49. // === CODE-CREATION-RULES ===
  50. // **Strict Typing**: Always use strict typing. Avoid using ambiguous or variant types.
  51. // **Primitive Types**: Favor the use of primitive types wherever possible.
  52. // **Portability Mandate**: Python code must be written with the intent to be ported to Java, Go, and JavaScript. Consider language-agnostic logic and avoid platform-specific dependencies.
  53. // **No Side Effects**: Functions should be pure, meaning their output should only be determined by their input without any observable side effects.
  54. // **Testability**: Ensure that every function and method is easily testable. Avoid tight coupling and consider dependency injection where applicable.
  55. // **Documentation**: Every function, method, and module should be thoroughly documented, especially if there's a nuance that's not directly evident from its signature.
  56. // **Contractual Obligation**: The definitions provided in this IDL are a strict contract. All specified interfaces, methods, and constraints must be implemented precisely as defined without deviation.
  57. // =======================
  58. // == !! BEGIN TEMPLATE EXAMPLE !! ===
  59. interface Tweets { // Preconditions: // - userID exists. // - tweetContent is non-null and within allowable size limits. // Postconditions: // - A new tweet is created and stored. // Expected JSON format: { "userID": "string", "content": "string" } void postTweet(string tweetJSON); // Preconditions: // - userID and tweetID exist. // Postconditions: // - The tweet with tweetID is marked as liked by userID. void likeTweet(string userID, string tweetID); // Preconditions: // - userID and tweetID exist. // Postconditions: // - The tweet with tweetID is marked as retweeted by userID. // Expected JSON format: { "userID": "string", "originalTweetID": "string" } void retweet(string retweetJSON); // Preconditions: // - tweetID exists. // Postconditions: // - Returns the details of the tweet as JSON. string getTweetDetails(string tweetID); // Invariants: // - Filesystem storage maintains a list of tweets, likes, and retweets for each tweetID. };
  60. // == !! END TEMPLATE EXAMPLE !! ===
  61.  
  62.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement