This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import "fmt" | |
| type Claim struct { | |
| ID string | |
| Amount int | |
| } | |
| type Insurer struct { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using System.Collections.Generic; | |
| namespace ClaimsProcessing | |
| { | |
| public class Claim | |
| { | |
| public string Id { get; set; } | |
| public decimal Amount { get; set; } | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.util.ArrayList; | |
| import java.util.List; | |
| class Claim { | |
| String id; | |
| int amount; | |
| public Claim(String id, int amount) { | |
| this.id = id; | |
| this.amount = amount; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| interface AbstractionLayer { | |
| createUser(); | |
| } | |
| class MongoDbAdapter implements AbstractionLayer { | |
| createUser() { | |
| // Mongodb specific code | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const ClientWrapper = require('./mongo-client-wrapper.js'); | |
| ClientWrapper("url/to/mongodb").then((db) => { | |
| db.insert(); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| app.post('/comments', (req, res, next) => { | |
| try { | |
| const { userId, postId } = req.body; | |
| const comment = db.createCommentSync(req.body); | |
| const post = db.getPostSync(postId); | |
| db.updatePostSync(postId, { comments: post.comments + 1 }); | |
| const user = db.getUserSync(userId); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| app.get('/users/:userId', (req, res) => { | |
| db.getUserAsync(req.params.userId, (err, user) => { | |
| db.getPostsByUserAsync(user.id, (err, posts) => { | |
| db.getCommentsByPostsAsync(posts, (err, comments) => { | |
| res.json(mergeData(user, posts, comments)); | |
| }); | |
| }); | |
| }); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| app.get('/users', (req, res) => { | |
| const users = db.getUsersAsync((err, data) => { | |
| console.log(data); | |
| return data; | |
| }); | |
| res.send(users); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function resolveKeyString(obj, keyString) { | |
| return keyString.split('.').reduce(function(p, c) { | |
| return p[c]; | |
| }, t); | |
| } | |
| // Usage: | |
| var obj = { | |
| a: { | |
| b: { |